Closed BhautikVaghasiya closed 1 month ago
Provide steps to reproduce please.
I don't understand. If you want to run code when alarm rings then modify the navigateToRingScreen
callback.
ringSubscription ??= Alarm.ringStream.stream.listen(navigateToRingScreen); if user tap to cancel alarm button so not navigateToRingScreen.
In the example app, the cancel button means that you want to cancel the editing or creating of the alarm. If you want to cancel the alarm you have to press the stop button.
Ok I understand now.
You need to listen for the Alarm.updateStream
and in its callback you need to check if an alarm is ringing. If not, then navigate back to your home screen.
https://github.com/user-attachments/assets/fe4a74cf-fa74-4802-8579-3d3369844c69 how to change font size. recived alarm notification.
No, it is not possible (tell me if you think I'm wrong) to change the font size of the notification action buttons. The action buttons in notifications have a fixed style defined by the system and cannot be customized.
Use Alarm.isRinging
method.
Set this:
updateSubscription ??= Alarm.updateStream.stream.listen(onAlarmsUpdate);
with callback:
Future<void> onAlarmsUpdate(int id) async {
loadAlarms();
var isAnyAlarmRinging = false;
for (final alarm in alarms) {
final alarmIsRinging = await Alarm.isRinging(alarm.id);
if (alarmIsRinging) {
isAnyAlarmRinging = true;
break;
}
}
if (mounted && !isAnyAlarmRinging && Navigator.canPop(context)) {
Navigator.pop(context);
}
}
when tap the cancel alarm button so redirects to ring screen this is the wrong @override void initState() { super.initState(); AlarmPermissions.checkNotificationPermission(); if (Alarm.android) { AlarmPermissions.checkAndroidScheduleExactAlarmPermission(); } loadAlarms(); ringSubscription ??= Alarm.ringStream.stream.listen(navigateToRingScreen); updateSubscription ??= Alarm.updateStream.stream.listen((_) { loadAlarms(); }); }