flutter_alarmkit 0.2.0
flutter_alarmkit: ^0.2.0 copied to clipboard
Flutter plugin for Apple AlarmKit (iOS 26+). Schedule one-shot, countdown, and recurring alarms as Lock Screen and Dynamic Island Live Activities.
flutter_alarmkit #
A Flutter plugin that provides access to Apple's AlarmKit framework, introduced in iOS 26 (WWDC 2025). This plugin allows you to schedule and manage prominent alarms and countdowns in your Flutter applications on iOS devices.
Your alarms will ring even when Do Not Disturb is enabled or if the app has been terminated.
See more: https://developer.apple.com/documentation/alarmkit
Features #
Available features #
- Request authorization to schedule alarms
- Schedule one-shot alarms
- Schedule countdown alarms
- Schedule recurrent alarms
- Listen to alarm updates
- Set custom alarm sounds
- Customize the Live Activity UI (buttons, icons, colors, titles)
- Cancel alarms
- Stop alarms
Installation #
Please carefully follow the installation steps in InstallationSteps.md. Most of it is automated:
dart run flutter_alarmkit:setup # patches your iOS project
dart run flutter_alarmkit:setup --doctor # verifies every step
Using Claude Code? This repo includes a
flutter-alarmkit-setupskill that drives the whole install for you. See Using with Claude Code.
Note: the plugin supports both Swift Package Manager and CocoaPods, and needs no
Podfilechanges. The Live Activity Widget Extension is a standalone WidgetKit target with no plugin dependency, so the setup is the same whichever dependency manager your app uses.
Usage #
Request Authorization #
Before scheduling any alarms, you need to request authorization from the user:
import 'package:flutter_alarmkit/flutter_alarmkit.dart';
try {
final isAuthorized = await FlutterAlarmkit().requestAuthorization();
if (isAuthorized) {
print('Alarm authorization granted');
} else {
print('Alarm authorization denied or not determined');
}
} catch (e) {
print('Error requesting authorization: $e');
}
Listen to alarm updates #
To listen to alarm updates (when alarms are added, updated, or removed):
final stream = FlutterAlarmkit().alarmUpdates();
stream.listen((alarmUpdate) {
print('Alarm updated: $alarmUpdate');
});
Schedule a One-Shot Alarm #
To schedule a one-time alarm:
try {
final alarmId = await FlutterAlarmkit().scheduleOneShotAlarm(
// timestamp is a Unix timestamp in milliseconds since epoch
timestamp: DateTime.now()
.add(const Duration(hours: 1))
.millisecondsSinceEpoch
.toDouble(),
label: 'My Alarm',
);
print('Alarm scheduled with ID: $alarmId');
} catch (e) {
print('Error scheduling alarm: $e');
}
Schedule a Countdown Alarm #
To schedule a countdown alarm:
final alarmId = await FlutterAlarmkit().setCountdownAlarm(
countdownDurationInSeconds: 10, // Duration before the alarm triggers
repeatDurationInSeconds: 5, // Duration between each repetition
label: 'My Countdown Alarm',
tintColor: '#0000FF',
);
Schedule a Recurrent Alarm #
To schedule a recurrent alarm:
final alarmId = await FlutterAlarmkit().scheduleRecurrentAlarm(
weekdays: {Weekday.monday, Weekday.wednesday, Weekday.friday},
hour: 10,
minute: 0,
label: 'My Recurrent Alarm',
tintColor: '#0000FF',
);
Customize the Live Activity UI #
All schedule methods accept an optional uiConfig to customize the Live Activity's buttons (text, SF Symbol icon, text color, tint color) and the countdown/paused titles:
final alarmId = await FlutterAlarmkit().setCountdownAlarm(
countdownDurationInSeconds: 60,
repeatDurationInSeconds: 10,
label: 'Tea timer',
uiConfig: const AlarmUIConfig(
stopButton: AlarmButtonConfig(
text: 'Done',
icon: 'checkmark.circle',
textColor: '#FFFFFF',
tintColor: '#FF3B30',
),
pauseButton: AlarmButtonConfig(text: 'Hold', icon: 'pause.fill'),
resumeButton: AlarmButtonConfig(text: 'Go', icon: 'play.fill'),
countdownTitle: 'Steeping...',
pausedTitle: 'On hold',
),
);
Every field is optional — anything you leave null keeps the standard AlarmKit appearance. Custom tint colors require the App Group from the installation steps.
Cancel an Alarm #
To cancel an alarm:
await FlutterAlarmkit().cancelAlarm(alarmId: alarmId);
Stop an Alarm #
To stop an alarm:
await FlutterAlarmkit().stopAlarm(alarmId: alarmId);
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
License #
This project is licensed under the MIT License - see the LICENSE file for details.