From 61189032bda7fb5cabe56910ea0d828787457637 Mon Sep 17 00:00:00 2001 From: Dolev Franco Date: Fri, 21 Jul 2023 10:48:36 +0300 Subject: [PATCH 1/2] fix: alarm rings NOW in DateTime.now --- lib/src/android_alarm.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/android_alarm.dart b/lib/src/android_alarm.dart index 88eaf5a8..3fec2874 100644 --- a/lib/src/android_alarm.dart +++ b/lib/src/android_alarm.dart @@ -67,6 +67,17 @@ class AndroidAlarm { throw AlarmException('Isolate error: $e'); } + if (dateTime.difference(DateTime.now()).inSeconds <= 1) { + await playAlarm(id, { + "assetAudioPath": assetAudioPath, + "loopAudio": loopAudio, + "vibrate": vibrate, + "fadeDuration": fadeDuration.toInt(), + "enableNotificationOnKill": enableNotificationOnKill, + }); + return true; + } + final res = await AndroidAlarmManager.oneShotAt( dateTime, id, From 280a837c168cf068e1f7ae663e97e4cf0d91ad9e Mon Sep 17 00:00:00 2001 From: Dolev Franco Date: Mon, 2 Oct 2023 17:10:14 +0300 Subject: [PATCH 2/2] refactor: remove vibrate and enableNotificationOnKill params from ring now --- lib/src/android_alarm.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/android_alarm.dart b/lib/src/android_alarm.dart index 6bd68fe0..0a561370 100644 --- a/lib/src/android_alarm.dart +++ b/lib/src/android_alarm.dart @@ -70,13 +70,11 @@ class AndroidAlarm { throw AlarmException('Isolate error: $e'); } - if (dateTime.difference(DateTime.now()).inSeconds <= 1) { + if (settings.dateTime.difference(DateTime.now()).inSeconds <= 1) { await playAlarm(id, { - "assetAudioPath": assetAudioPath, - "loopAudio": loopAudio, - "vibrate": vibrate, - "fadeDuration": fadeDuration.toInt(), - "enableNotificationOnKill": enableNotificationOnKill, + "assetAudioPath": settings.assetAudioPath, + "loopAudio": settings.loopAudio, + "fadeDuration": settings.fadeDuration.toInt(), }); return true; }