1+ import 'package:flutter_local_notifications/flutter_local_notifications.dart' ;
12import 'package:get_storage/get_storage.dart' ;
23import 'package:isolate_handler/isolate_handler.dart' ;
34import 'package:timezone/timezone.dart' as tz;
45import 'package:waktusolatmalaysia/utils/debug_toast.dart' ;
56import '../CONSTANTS.dart' ;
67import '../locationUtil/locationDatabase.dart' ;
7- import '../main.dart' ;
88import 'notifications_helper.dart' ;
99
1010// https://gist.github.com/taciomedeiros/50472cf94c742befba720853e9d598b6
1111
1212final IsolateHandler isolateHandler = IsolateHandler ();
13+ final _notifsPlugin = FlutterLocalNotificationsPlugin ();
1314DateTime currentDate = DateTime .now ();
1415
1516void schedulePrayNotification (List <dynamic > times) async {
16- await notifsPlugin .cancelAll (); //reset all
17+ await _notifsPlugin .cancelAll (); //reset all
1718
1819 String currentLocation =
1920 LocationDatabase .getDaerah (GetStorage ().read (kStoredGlobalIndex));
@@ -46,7 +47,7 @@ void schedulePrayNotification(List<dynamic> times) async {
4647 //to make sure the time is in future
4748 await schedulePrayerNotification (
4849 name: 'Fajr' ,
49- notifsPlugin: notifsPlugin ,
50+ notifsPlugin: _notifsPlugin ,
5051 id: (subuhTimeEpoch / 1000 ).truncate (),
5152 title: 'It\' s Subuh' ,
5253 scheduledTime: tz.TZDateTime .from (
@@ -57,7 +58,7 @@ void schedulePrayNotification(List<dynamic> times) async {
5758 if (! (syurukTimeEpoch < currentTime)) {
5859 await schedulePrayerNotification (
5960 name: 'Syuruk' ,
60- notifsPlugin: notifsPlugin ,
61+ notifsPlugin: _notifsPlugin ,
6162 id: (syurukTimeEpoch / 1000 ).truncate (),
6263 title: 'It\' s Syuruk' ,
6364 body: 'in ' + currentLocation,
@@ -67,7 +68,7 @@ void schedulePrayNotification(List<dynamic> times) async {
6768 if (! (zuhrTimeEpoch < currentTime)) {
6869 await schedulePrayerNotification (
6970 name: 'Zuhr' ,
70- notifsPlugin: notifsPlugin ,
71+ notifsPlugin: _notifsPlugin ,
7172 id: (zuhrTimeEpoch / 1000 ).truncate (),
7273 title: 'It\' s Zohor' ,
7374 body: 'in ' + currentLocation,
@@ -77,7 +78,7 @@ void schedulePrayNotification(List<dynamic> times) async {
7778 if (! (asarTimeEpoch < currentTime)) {
7879 await schedulePrayerNotification (
7980 name: 'Asr' ,
80- notifsPlugin: notifsPlugin ,
81+ notifsPlugin: _notifsPlugin ,
8182 id: (asarTimeEpoch / 1000 ).truncate (),
8283 title: 'It\' s Asar' ,
8384 body: 'in ' + currentLocation,
@@ -87,7 +88,7 @@ void schedulePrayNotification(List<dynamic> times) async {
8788 if (! (maghribTimeEpoch < currentTime)) {
8889 await schedulePrayerNotification (
8990 name: 'Maghrib' ,
90- notifsPlugin: notifsPlugin ,
91+ notifsPlugin: _notifsPlugin ,
9192 id: (maghribTimeEpoch / 1000 ).truncate (),
9293 title: 'It\' s Maghrib' ,
9394 body: 'in ' + currentLocation,
@@ -97,7 +98,7 @@ void schedulePrayNotification(List<dynamic> times) async {
9798 if (! (isyakTimeEpoch < currentTime)) {
9899 await schedulePrayerNotification (
99100 name: 'Isya\' ' ,
100- notifsPlugin: notifsPlugin ,
101+ notifsPlugin: _notifsPlugin ,
101102 id: (isyakTimeEpoch / 1000 ).truncate (),
102103 title: 'It\' s Isyak' ,
103104 body: 'in ' + currentLocation,
@@ -109,7 +110,7 @@ void schedulePrayNotification(List<dynamic> times) async {
109110 }
110111
111112 scheduleAlertNotification (
112- notifsPlugin: notifsPlugin ,
113+ notifsPlugin: _notifsPlugin ,
113114 id: 2190 ,
114115 title: 'Monthly refresh reminder' ,
115116 body:
0 commit comments