[READ-ONLY] Mirror of https://github.com/probablykasper/notifier. Android app for scheduling notifications
android app flutter notifications
0

Configure Feed

Select the types of activity you want to include in your feed.

Add android_alarm_manager_plus

+57 -23
+9 -11
android/app/src/main/AndroidManifest.xml
··· 1 1 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 2 package="com.example.notifier"> 3 3 4 - <!-- For android_alarm_manager_plus --> 5 - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 6 - <!-- For android_alarm_manager_plus --> 7 - <uses-permission android:name="android.permission.WAKE_LOCK"/> 8 - <!-- For android_alarm_manager_plus --> 4 + <!-- Start Alarm Manager --> 9 5 <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> 6 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 7 + <uses-permission android:name="android.permission.WAKE_LOCK" /> 8 + <!-- End Alarm Manager --> 10 9 11 10 <application 12 11 android:label="notifier" ··· 39 38 android:name="flutterEmbedding" 40 39 android:value="2" /> 41 40 42 - <!-- For android_alarm_manager_plus --> 41 + <!-- Start Alarm Manager --> 43 42 <service 44 43 android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmService" 45 - android:permission="android.permission.BIND_JOB_SERVICE" 46 - android:exported="false"/> 47 - <!-- For android_alarm_manager_plus --> 44 + android:exported="false" 45 + android:permission="android.permission.BIND_JOB_SERVICE" /> 48 46 <receiver 49 47 android:name="dev.fluttercommunity.plus.androidalarmmanager.AlarmBroadcastReceiver" 50 - android:exported="false"/> 51 - <!-- For android_alarm_manager_plus --> 48 + android:exported="false" /> 52 49 <receiver 53 50 android:name="dev.fluttercommunity.plus.androidalarmmanager.RebootBroadcastReceiver" 54 51 android:enabled="false" ··· 57 54 <action android:name="android.intent.action.BOOT_COMPLETED" /> 58 55 </intent-filter> 59 56 </receiver> 57 + <!-- End Alarm Manager --> 60 58 61 59 </application> 62 60 </manifest>
+3
lib/list_page.dart
··· 30 30 Widget; 31 31 import 'package:get/state_manager.dart'; 32 32 import 'package:notifier/edit_dialog.dart'; 33 + import 'package:notifier/scheduler.dart'; 33 34 import 'notification_item.dart' show NotificationItem; 34 35 import 'theme.dart' show CustomTheme, toggleDarkMode; 35 36 ··· 52 53 editMode: false, 53 54 onSave: (item) { 54 55 c.items.add(item); 56 + scheduleNotifications(); 55 57 }, 56 58 )); 57 59 }), ··· 112 114 editMode: true, 113 115 onSave: (item) { 114 116 c.items[index] = item; 117 + scheduleNotifications(); 115 118 }, 116 119 )); 117 120 },
+19 -12
lib/main.dart
··· 1 + import 'dart:isolate'; 2 + 1 3 import 'package:flutter/material.dart' show ThemeMode, runApp; 2 - // import 'package:notifier/notification_items.dart' show scheduleNotifications; 4 + import 'package:notifier/scheduler.dart' show scheduleNotifications; 3 5 import 'theme.dart' show getTheme, initializeTheme; 4 6 import 'list_page.dart' show ListPage; 5 7 import 'package:shared_preferences/shared_preferences.dart' 6 8 show SharedPreferences; 7 9 import 'package:get/get.dart' show GetMaterialApp; 8 - // import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart' 9 - // show AndroidAlarmManager; 10 + import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; 10 11 11 12 var prefsFuture = SharedPreferences.getInstance(); 12 13 14 + void printHello() { 15 + final DateTime now = DateTime.now(); 16 + final int isolateId = Isolate.current.hashCode; 17 + print("[$now] Hello, world! isolate=$isolateId"); 18 + } 19 + 13 20 void main() async { 14 21 // Be sure to add this line if AndroidAlarmManager.initialize() call happens before runApp() 15 22 // WidgetsFlutterBinding.ensureInitialized(); 16 23 17 - // await AndroidAlarmManager.initialize(); 18 - 19 24 runApp( 20 25 GetMaterialApp( 21 - title: 'Notifier', 22 - // debugShowCheckedModeBanner: false, 23 - theme: getTheme(false), 24 - darkTheme: getTheme(true), 25 - themeMode: ThemeMode.system, 26 - home: ListPage()), 26 + title: 'Notifier', 27 + debugShowCheckedModeBanner: false, 28 + theme: getTheme(false), 29 + darkTheme: getTheme(true), 30 + themeMode: ThemeMode.system, 31 + home: ListPage(), 32 + ), 27 33 ); 28 34 initializeTheme(); 29 35 30 - // scheduleNotifications(); 36 + await AndroidAlarmManager.initialize(); 37 + scheduleNotifications(); 31 38 }
+18
lib/scheduler.dart
··· 1 + import 'dart:isolate' show Isolate; 2 + import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart' 3 + show AndroidAlarmManager; 4 + 5 + const mainAlarmId = 0; 6 + 7 + void scheduleNotifications() async { 8 + handler(); 9 + await AndroidAlarmManager.periodic( 10 + const Duration(minutes: 1), mainAlarmId, handler, 11 + rescheduleOnReboot: true); 12 + } 13 + 14 + void handler() async { 15 + final DateTime now = DateTime.now(); 16 + final int isolateId = Isolate.current.hashCode; 17 + print("[$now] Hello, world! isolate=$isolateId"); 18 + }
+7
pubspec.lock
··· 1 1 # Generated by pub 2 2 # See https://dart.dev/tools/pub/glossary#lockfile 3 3 packages: 4 + android_alarm_manager_plus: 5 + dependency: "direct main" 6 + description: 7 + name: android_alarm_manager_plus 8 + url: "https://pub.dartlang.org" 9 + source: hosted 10 + version: "2.0.5" 4 11 async: 5 12 dependency: transitive 6 13 description:
+1
pubspec.yaml
··· 38 38 get: ^4.6.5 39 39 awesome_notifications: ^0.6.21 40 40 intl: ^0.17.0 41 + android_alarm_manager_plus: ^2.0.5 41 42 42 43 dev_dependencies: 43 44 flutter_test: