This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Conversation { | |
| String id; | |
| // conversation name for example chat with market name | |
| String name; | |
| // Chats messages | |
| String lastMessage; | |
| int lastMessageTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future<void> sendNotification(String body, String title, User user) async { | |
| final data = { | |
| "notification": {"body": "$body", "title": "$title"}, | |
| "priority": "high", | |
| "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK", "id": "messages", "status": "done"}, | |
| "to": "${user.deviceToken}" | |
| }; | |
| final String url = 'https://fcm.googleapis.com/fcm/send'; | |
| final client = new http.Client(); | |
| final response = await client.post( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| addMessage(Conversation _conversation, String text) { | |
| Chat _chat = new Chat(text, DateTime.now().toUtc().millisecondsSinceEpoch, currentUser.value.id); | |
| if (_conversation.id == null) { | |
| _conversation.id = UniqueKey().toString(); | |
| createConversation(_conversation); | |
| } | |
| _conversation.lastMessage = text; | |
| _conversation.lastMessageTime = _chat.time; | |
| _conversation.readByUsers = [currentUser.value.id]; | |
| _chatRepository.addMessage(_conversation, _chat).then((value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| import 'package:dropdownfield/dropdownfield.dart'; | |
| import 'package:fl_chart/fl_chart.dart'; | |
| import 'package:flutter/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/widgets.dart'; | |
| import 'package:searchable_dropdown/searchable_dropdown.dart'; | |
| import 'package:transit/Login.dart'; | |
| import 'package:http/http.dart' as http; | |
| import 'package:shared_preferences/shared_preferences.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
| public static String getForegroundProcess(Context context) { | |
| String topPackageName = null; | |
| UsageStatsManager usage = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE); | |
| long time = System.currentTimeMillis(); | |
| List<UsageStats> stats = usage.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000*1000, time); | |
| if (stats != null) { | |
| SortedMap<Long, UsageStats> runningTask = new TreeMap<Long,UsageStats>(); | |
| for (UsageStats usageStats : stats) { | |
| runningTask.put(usageStats.getLastTimeUsed(), usageStats); |