mshetrbinrjdefg
This commit is contained in:
parent
a057d91493
commit
ef17a0b4a0
|
@ -65,14 +65,17 @@ void scheduleNotification() async {
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// For all entries in the past, add 1 day
|
// For all entries in the past, add 1 day
|
||||||
for (var time in notificationTimes
|
for (var time
|
||||||
.where((element) => element.compareTo(currentTime) < 0)) {
|
in notificationTimes.where((time) => time.compareTo(currentTime) < 0)) {
|
||||||
time.add(const Duration(days: 1));
|
notificationTimes.remove(time);
|
||||||
|
notificationTimes.add(time.add(const Duration(days: 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the array so we can find the closest time
|
// Sort the array so we can find the closest time
|
||||||
notificationTimes.sort((a, b) => a.compareTo(b));
|
notificationTimes.sort((a, b) => a.compareTo(b));
|
||||||
|
|
||||||
|
print("Scheduling notification for ${notificationTimes[0].toString()}");
|
||||||
|
|
||||||
await FlutterLocalNotificationsPlugin().zonedSchedule(
|
await FlutterLocalNotificationsPlugin().zonedSchedule(
|
||||||
1,
|
1,
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -11,7 +11,7 @@ void callbackDispatcher() {
|
||||||
print("Native called background task: $taskName");
|
print("Native called background task: $taskName");
|
||||||
|
|
||||||
if (taskName == 'scheduleNotifications') {
|
if (taskName == 'scheduleNotifications') {
|
||||||
sendNotification();
|
scheduleNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue