From 34afa0618d44a9a3d855087a656229fd921cc113 Mon Sep 17 00:00:00 2001 From: Dolev Franco Date: Tue, 3 Oct 2023 11:25:32 +0300 Subject: [PATCH] [Android] Fix: Alarm rings NOW in DateTime.now (in a difference of 1 sec) (#68) * fix: alarm rings NOW in DateTime.now * refactor: remove vibrate and enableNotificationOnKill params from ring now --- lib/src/android_alarm.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/android_alarm.dart b/lib/src/android_alarm.dart index 395b2850..0a561370 100644 --- a/lib/src/android_alarm.dart +++ b/lib/src/android_alarm.dart @@ -70,6 +70,15 @@ class AndroidAlarm { throw AlarmException('Isolate error: $e'); } + if (settings.dateTime.difference(DateTime.now()).inSeconds <= 1) { + await playAlarm(id, { + "assetAudioPath": settings.assetAudioPath, + "loopAudio": settings.loopAudio, + "fadeDuration": settings.fadeDuration.toInt(), + }); + return true; + } + final res = await AndroidAlarmManager.oneShotAt( settings.dateTime, id,