From ef17a0b4a0994d2a613b6888809697c9b4a88bb4 Mon Sep 17 00:00:00 2001 From: Lea Date: Fri, 6 Oct 2023 14:49:56 +0200 Subject: [PATCH] mshetrbinrjdefg --- lib/notification.dart | 9 ++++++--- lib/tasks.dart | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/notification.dart b/lib/notification.dart index 3e79173..35794ca 100644 --- a/lib/notification.dart +++ b/lib/notification.dart @@ -65,14 +65,17 @@ void scheduleNotification() async { .toList(); // For all entries in the past, add 1 day - for (var time in notificationTimes - .where((element) => element.compareTo(currentTime) < 0)) { - time.add(const Duration(days: 1)); + for (var time + in notificationTimes.where((time) => time.compareTo(currentTime) < 0)) { + notificationTimes.remove(time); + notificationTimes.add(time.add(const Duration(days: 1))); } // Sort the array so we can find the closest time notificationTimes.sort((a, b) => a.compareTo(b)); + print("Scheduling notification for ${notificationTimes[0].toString()}"); + await FlutterLocalNotificationsPlugin().zonedSchedule( 1, null, diff --git a/lib/tasks.dart b/lib/tasks.dart index 7628be0..9830630 100644 --- a/lib/tasks.dart +++ b/lib/tasks.dart @@ -11,7 +11,7 @@ void callbackDispatcher() { print("Native called background task: $taskName"); if (taskName == 'scheduleNotifications') { - sendNotification(); + scheduleNotification(); } return true;