### Android Icon Setup Example Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/notification_settings.md Example demonstrating how to set a custom notification icon for Android. ```APIDOC ## Icon Setup (Android) ### Description Instructions and an example for setting a custom monochrome notification icon on Android. ### Requirements - Monochrome (light or dark) on transparent background - PNG or XML format - 24x24 dp size recommended - If null, uses app's default icon ### Example ```dart NotificationSettings( title: 'Alarm', body: 'Wake up!', icon: 'notification_icon', // refers to notification_icon.png ) ``` ``` -------------------------------- ### Full Integration Example Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/notification_settings.md Integrate alarm settings with comprehensive notification customization. This example shows how to set an alarm with a specific audio file and detailed notification preferences. ```dart final alarmSettings = AlarmSettings( id: 1, dateTime: DateTime.now().add(Duration(minutes: 5)), assetAudioPath: 'assets/alarm.mp3', notificationSettings: NotificationSettings( title: 'Wake Up!', body: 'Your alarm is ringing', stopButton: 'Stop Alarm', icon: 'notification_icon', iconColor: const Color(0xFF4CAF50), keepNotificationAfterAlarmEnds: false, ), volumeSettings: VolumeSettings.fixed(volume: 0.8), ); await Alarm.set(alarmSettings: alarmSettings); ``` -------------------------------- ### Usage Example for Alarm Streams Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/types.md Demonstrates how to access the current value of the scheduled alarms stream and how to listen for changes. This example shows immediate value retrieval and reactive updates. ```dart // Get current scheduled alarms immediately final current = Alarm.scheduled.value; // Listen for changes Alarm.scheduled.listen((alarmSet) { print('Scheduled alarms changed: ${alarmSet.alarms}'); }); ``` -------------------------------- ### Audio Path Formats Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Examples of how to specify audio paths for alarms, including project assets, documents folder, and device default. ```dart assetAudioPath: 'assets/alarm.mp3' ``` ```dart assetAudioPath: 'sounds/custom.mp3' // relative to Documents ``` ```dart assetAudioPath: null ``` -------------------------------- ### Complete Alarm Configuration with Volume Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md This example shows how to create a full `AlarmSettings` object, including detailed `VolumeSettings`, and then schedule the alarm using `Alarm.set()`. ```dart final alarmSettings = AlarmSettings( id: 1, dateTime: DateTime.now().add(Duration(minutes: 10)), assetAudioPath: 'assets/alarm.mp3', volumeSettings: VolumeSettings.fade( volume: 0.8, fadeDuration: Duration(seconds: 10), volumeEnforced: true, showSystemUI: true, ), notificationSettings: const NotificationSettings( title: 'Alarm', body: 'Time to wake up', ), ); await Alarm.set(alarmSettings: alarmSettings); ``` -------------------------------- ### Complete Alarm Configuration Example Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/configuration.md Demonstrates how to initialize the Alarm service and schedule a new alarm with various customizable settings including audio, vibration, notifications, and volume. ```dart import 'package:alarm/alarm.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize alarm service await Alarm.init(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( home: const HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); Future scheduleAlarm() async { try { final now = DateTime.now(); final alarmTime = now.add(Duration(minutes: 10)); final alarmSettings = AlarmSettings( id: 1, dateTime: alarmTime, assetAudioPath: 'assets/alarm.mp3', loopAudio: true, vibrate: true, warningNotificationOnKill: true, androidFullScreenIntent: true, allowAlarmOverlap: false, allowSameSecondScheduling: false, iOSBackgroundAudio: true, androidStopAlarmOnTermination: true, preferConnectedAudioDevice: false, payload: 'example_alarm', volumeSettings: VolumeSettings.fade( volume: 0.8, fadeDuration: Duration(seconds: 5), volumeEnforced: true, showSystemUI: true, ), notificationSettings: NotificationSettings( title: 'Good Morning!', body: 'Time to wake up', stopButton: 'Stop Alarm', icon: 'notification_icon', iconColor: Color(0xFF4CAF50), keepNotificationAfterAlarmEnds: false, ), ); await Alarm.set(alarmSettings: alarmSettings); print('Alarm scheduled for $alarmTime'); } catch (e) { print('Failed to schedule alarm: $e'); } } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( onPressed: scheduleAlarm, child: const Text('Schedule Alarm'), ), ), ); } } ``` -------------------------------- ### Usage Example for isSameSecond() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/types.md Demonstrates how to use the isSameSecond() extension method to compare DateTime objects. Shows cases where seconds match and where they differ. ```dart final dt1 = DateTime(2024, 1, 1, 12, 30, 45, 100); final dt2 = DateTime(2024, 1, 1, 12, 30, 45, 500); final dt3 = DateTime(2024, 1, 1, 12, 30, 46, 100); print(dt1.isSameSecond(dt2)); // true (same second, different ms) print(dt1.isSameSecond(dt3)); // false (different second) ``` -------------------------------- ### AppDelegate Setup for Notifications and Background Tasks Source: https://github.com/gdelataillade/alarm/blob/main/help/INSTALL-IOS.md Imports necessary modules and configures the app to handle foreground notifications and set up background tasks. Ensure `UNUserNotificationCenter` delegate is set and `SwiftAlarmPlugin.registerBackgroundTasks()` is called. ```swift import UserNotifications import alarm ``` ```swift if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate } SwiftAlarmPlugin.registerBackgroundTasks() ``` -------------------------------- ### Example Usage of AlarmSet Methods Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Demonstrates how to use contains(), add(), and remove() methods on an AlarmSet. Note that add() and remove() return new instances. ```dart final alarmSet = AlarmSet([alarm1, alarm2]); if (alarmSet.contains(alarm1)) { print('alarm1 is in the set'); } final originalSet = AlarmSet([alarm1]); final newSet = originalSet.add(alarm2); print(newSet.alarms.length); // 2 final originalSet2 = AlarmSet([alarm1, alarm2]); final newSet2 = originalSet2.remove(alarm1); print(newSet2.alarms.length); // 1 ``` -------------------------------- ### JSON Serialization and Deserialization Example Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_fade_step.md Demonstrates how to serialize a VolumeFadeStep object to JSON and then deserialize it back into a VolumeFadeStep instance. Ensure the JSON structure matches the expected format. ```dart // Create a step final step = VolumeFadeStep(Duration(seconds: 10), 0.5); // Serialize final json = step.toJson(); // Output: {'time': Duration(seconds: 10), 'volume': 0.5} // Deserialize final restored = VolumeFadeStep.fromJson(json); ``` -------------------------------- ### Initialize and Schedule Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Required setup and basic operations for scheduling alarms. Ensure Alarm.init() is called before any other operations. ```dart await Alarm.init(); ``` ```dart await Alarm.set(alarmSettings: alarmSettings); ``` -------------------------------- ### Handle Custom Alarm Exceptions Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/types.md Example demonstrating how to catch and inspect AlarmException objects. This allows for detailed logging and user feedback based on the error code, message, and stack trace. ```dart try { await Alarm.set(alarmSettings: alarmSettings); } on AlarmException catch (e) { print('Alarm error: ${e.code}'); print('Message: ${e.message}'); if (e.stacktrace != null) { print('Stack: ${e.stacktrace}'); } } ``` -------------------------------- ### Initialize Empty AlarmSet Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Creates an empty AlarmSet. This is useful for starting with a new collection before adding any alarms. ```dart AlarmSet.empty() ``` -------------------------------- ### AlarmSettings copyWith Method Example Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_settings.md Creates a modified copy of an AlarmSettings object by replacing specified fields. Use this method to update settings immutably. ```dart final updated = alarmSettings.copyWith( dateTime: DateTime.now().add(Duration(hours: 1)), loopAudio: false, ); ``` -------------------------------- ### Logging Alarm Events Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Illustrates how to log various alarm events using the Logger class. This includes informational messages for starting and stopping alarms, as well as severe errors. ```dart Logger('AlarmTriggerApiImpl').info('Alarm with id $alarmId started ringing.'); Logger('AlarmTriggerApiImpl').info('Alarm with id $alarmId stopped.'); Logger('AlarmTriggerApiImpl').severe('Alarm with id $alarmId started ringing but...'); ``` -------------------------------- ### Listen to Alarm Changes Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Listens for changes in the alarm state, such as when an alarm starts ringing. ```APIDOC ## Listen to Changes ### Description Listens for changes in the alarm state, such as when an alarm starts ringing. ### Method `Stream` ### Property `static Stream ringing` ### Example ```dart Alarm.ringing.listen((alarmSet) { if (alarmSet.alarms.isNotEmpty) { print('Alarm is ringing!'); } }); ``` ### Response #### Success Response (Stream) - **alarms** (List) - A list of currently active alarms. ``` -------------------------------- ### Get All Scheduled Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Use `Alarm.getAlarms()` to retrieve a list of all currently scheduled alarms. ```dart await Alarm.getAlarms(); ``` -------------------------------- ### init() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_storage.md Initializes the shared preferences instance and sets up foreground/background event listening. This is called automatically by Alarm.init(). ```APIDOC ## init() ### Description Initializes the shared preferences instance and sets up foreground/background event listening. This is called automatically by `Alarm.init()`. ### Method static Future init() ### Parameters There are no parameters for this method. ### Returns `Future` — Completes when initialization is done. ### Side Effects - Initializes shared preferences - Starts listening to foreground/background events - Reloads preferences when app comes to foreground ### Note Called automatically during `Alarm.init()`. Should not need to be called manually. ``` -------------------------------- ### Retrieve Alarm Details Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Get specific alarm information by ID or retrieve all scheduled alarms. ```dart final alarm = await Alarm.getAlarm(id); ``` ```dart final alarms = await Alarm.getAlarms(); ``` -------------------------------- ### Get All Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/INDEX.md Retrieves a list of all currently scheduled alarms. Returns a Future list of AlarmSettings. ```APIDOC ## Alarm.getAlarms() ### Description Get all alarms. ### Method `Alarm.getAlarms()` ### Parameters — ### Returns `Future>` ``` -------------------------------- ### Importing Alarm Implementations Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/base_alarm.md Demonstrates how to import the platform-specific alarm implementations. Direct import of BaseAlarm is not recommended; instead, use the iOS or Android specific imports. ```dart // Not typically imported directly import 'package:alarm/src/base_alarm.dart'; // Instead, use platform-specific implementations import 'package:alarm/src/ios_alarm.dart'; import 'package:alarm/src/android_alarm.dart'; ``` -------------------------------- ### Listen to Ringing Alarm Stream Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Subscribe to the `Alarm.ringing` stream to receive notifications when an alarm starts ringing. ```dart Alarm.ringing.listen(...); ``` -------------------------------- ### Deprecated ringStream Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm.md This is a legacy stream emitting AlarmSettings when they start ringing. Use the `ringing` stream instead. ```dart @Deprecated('Use [scheduled] and [ringing] streams instead.') static final ringStream = StreamController() ``` -------------------------------- ### Basic Alarm Lifecycle Management Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_storage.md Demonstrates the fundamental steps of initializing the alarm service, setting a new alarm, retrieving all saved alarms, and stopping a specific alarm. Saving and unsaving are handled automatically by `Alarm.set()` and `Alarm.stop()` respectively. ```dart // Initialize await Alarm.init(); // Create and save alarm final alarmSettings = AlarmSettings( id: 1, dateTime: DateTime.now().add(Duration(hours: 1)), // ... other settings ); await Alarm.set(alarmSettings: alarmSettings); // AlarmStorage.saveAlarm() is called automatically // Later, retrieve saved alarms final saved = await AlarmStorage.getSavedAlarms(); print('Saved alarms: ${saved.length}'); // Stop alarm, automatically removes from storage await Alarm.stop(1); ``` -------------------------------- ### init() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm.md Initializes the Alarm service. Must be called before using any other Alarm methods. Restores previously scheduled alarms from storage. ```APIDOC ## init() ### Description Initializes the Alarm service. Must be called before using any other Alarm methods. Restores previously scheduled alarms from storage. ### Method `static Future init()` ### Returns `Future` — Completes when initialization is done. ### Throws - `AlarmException` with code `pluginInternal` if initialization fails ### Example ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Alarm.init(); runApp(const MyApp()); } ``` ``` -------------------------------- ### iOS Recommended Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Use these settings for optimal performance on iOS. `warningNotificationOnKill` warns when the app is killed, and `iOSBackgroundAudio` helps keep the app alive. ```dart // Recommended settings for iOS AlarmSettings( // ... other settings warningNotificationOnKill: true, // Warn when app killed iOSBackgroundAudio: true, // Keep app alive ) ``` -------------------------------- ### Get a Specific Alarm Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Use `Alarm.getAlarm()` with the alarm ID to retrieve the settings for a specific scheduled alarm. ```dart await Alarm.getAlarm(id); ``` -------------------------------- ### Get Underlying Set of Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Retrieves the set of all alarms currently stored within the AlarmSet collection. ```dart Set get alarms ``` -------------------------------- ### Listen to Scheduled Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Subscribe to changes in scheduled alarms to get real-time updates on the number of active alarms. ```APIDOC ## Streams — Listen to Changes ### Scheduled Alarms ```dart Alarm.scheduled.listen((alarmSet) { print('Active alarms: ${alarmSet.alarms.length}'); }); ``` ``` -------------------------------- ### toWire() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Converts the VolumeSettings instance to a platform wire format for native platform communication. It converts Duration to milliseconds and VolumeFadeSteps to their wire format. ```APIDOC ## toWire() ### Description Converts to platform wire format for native platform communication. Converts Duration to milliseconds and VolumeFadeSteps to wire format. ### Method Instance method ### Parameters None ### Request Example ```dart VolumeSettingsWire toWire() ``` ### Response #### Success Response * **VolumeSettingsWire** - The volume settings in platform wire format. #### Response Example ```dart // Example of a VolumeSettingsWire object (structure depends on native implementation) { "volume": 0.8, "fadeDuration": 5000, "volumeEnforced": true } ``` ``` -------------------------------- ### Get Alarm by ID Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/INDEX.md Retrieves the settings for a specific alarm using its ID. Returns the AlarmSettings or null if not found. ```APIDOC ## Alarm.getAlarm() ### Description Get alarm by ID. ### Method `Alarm.getAlarm(int id)` ### Parameters #### Path Parameters - **id** (int) - Required - The ID of the alarm to retrieve. ### Returns `Future` ``` -------------------------------- ### Create VolumeSettings from JSON Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Use this factory constructor to create a VolumeSettings instance from a JSON map. Ensure the JSON object contains the necessary volume settings. ```dart factory VolumeSettings.fromJson(Map json) ``` -------------------------------- ### Setting Up Logging for Alarm Plugin Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/errors.md Configure the logging package to capture detailed error information from the alarm plugin. Ensure hierarchical logging is enabled and set the root logger level to ALL. ```dart import 'package:logging/logging.dart'; void setupLogging() { hierarchicalLoggingEnabled = true; Logger.root.level = Level.ALL; Logger.root.onRecord.listen((record) { print('[${record.loggerName}] ${record.level.name}: ${record.message}'); if (record.error != null) print('Error: ${record.error}'); if (record.stackTrace != null) print('Stack: ${record.stackTrace}'); }); } ``` -------------------------------- ### Get Current Alarm Value Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Retrieve the current value of scheduled and ringing alarms without subscribing to stream updates. ```APIDOC ### Get Current Value (No Subscription) ```dart final currentScheduled = Alarm.scheduled.value; final currentRinging = Alarm.ringing.value; ``` ``` -------------------------------- ### Create Fixed Volume Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Use this constructor for a constant volume level. Set `volumeEnforced` to true if the system should enforce this volume, or false to allow system overrides. ```dart final volumeSettings = VolumeSettings.fixed( volume: 0.8, volumeEnforced: false, ); ``` -------------------------------- ### Restoring Alarms on App Startup Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_storage.md Shows how to initialize the alarm service in the `main` function. `Alarm.init()` automatically handles the restoration of saved alarms by checking their trigger times and rescheduling future ones, as well as managing currently ringing alarms. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize alarm service await Alarm.init(); // This internally calls checkAlarm() which: // 1. Gets all saved alarms from storage // 2. Reschedules alarms with future trigger times // 3. Handles alarms that are already ringing runApp(const MyApp()); } ``` -------------------------------- ### Listen for Alarm Ringing Events Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Subscribe to the Alarm.ringing stream to be notified when an alarm starts ringing and access the set of active alarms. ```dart Alarm.ringing.listen((alarmSet) { if (alarmSet.alarms.isNotEmpty) { print('Alarm is ringing!'); } }); ``` -------------------------------- ### Create Smooth Fade Volume Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Configure a volume that smoothly transitions over a specified duration. `volumeEnforced` ensures the system adheres to the set volume during the fade. ```dart final volumeSettings = VolumeSettings.fade( volume: 1.0, fadeDuration: Duration(seconds: 5), volumeEnforced: true, ); ``` -------------------------------- ### Monitor Scheduled Alarms Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm.md Listen to this stream to get updates on the set of scheduled alarms. It emits an AlarmSet whenever the schedule changes. ```dart static ValueStream get scheduled ``` ```dart Alarm.scheduled.listen((alarmSet) { print('Scheduled alarms: ${alarmSet.alarms}'); }); ``` -------------------------------- ### AlarmSettings.toWire() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_settings.md Converts the AlarmSettings instance to a platform wire format for native communication. ```APIDOC ## toWire() ### Description Converts to platform wire format for native platform communication. ### Method AlarmSettingsWire toWire() ### Parameters None ### Request Example None ### Response #### Success Response (200) - **AlarmSettingsWire** - The platform wire format representation of the alarm settings. ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Listen to Legacy Alarm Ring Stream (Deprecated) Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/configuration.md This is a deprecated stream for listening to when alarms start ringing. Use the `Alarm.ringing` stream instead. ```dart Alarm.ringStream.listen((alarmSettings) { print('Alarm ${alarmSettings.id} started ringing'); }); ``` -------------------------------- ### Basic Flutter App Structure with Alarm Integration Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Sets up a basic MaterialApp with a HomePage that integrates alarm functionality. It includes listening for ringing alarms and displaying the count of scheduled alarms. ```dart class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( home: const HomePage(), ); } } class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State createState() => _HomePageState(); } class _HomePageState extends State { @override void initState() { super.initState(); // Listen to ringing alarms Alarm.ringing.listen((alarmSet) { if (alarmSet.alarms.isNotEmpty) { _showSnackBar('Alarm is ringing!'); } }); } Future _scheduleAlarm() async { try { final alarmSettings = AlarmSettings( id: DateTime.now().millisecondsSinceEpoch ~/ 1000, dateTime: DateTime.now().add(Duration(seconds: 30)), assetAudioPath: 'assets/alarm.mp3', loopAudio: true, vibrate: true, notificationSettings: const NotificationSettings( title: 'Test Alarm', body: 'This is a test alarm', stopButton: 'Stop', ), volumeSettings: VolumeSettings.fade( volume: 0.8, fadeDuration: Duration(seconds: 3), ), ); await Alarm.set(alarmSettings: alarmSettings); _showSnackBar('Alarm scheduled!'); } on AlarmException catch (e) { _showSnackBar('Error: ${e.message}'); } } Future _stopAllAlarms() async { await Alarm.stopAll(); _showSnackBar('All alarms stopped'); } void _showSnackBar(String message) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(message)), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Alarm Demo')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ StreamBuilder( stream: Alarm.scheduled, builder: (context, snapshot) { final alarmCount = snapshot.data?.alarms.length ?? 0; return Text('Scheduled: $alarmCount alarm(s)'); }, ), const SizedBox(height: 20), ElevatedButton( onPressed: _scheduleAlarm, child: const Text('Schedule Alarm (30s)'), ), const SizedBox(height: 10), ElevatedButton( onPressed: _stopAllAlarms, child: const Text('Stop All'), ), ], ), ), ); } } ``` -------------------------------- ### fromJson() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Creates a VolumeSettings instance from JSON data. This method is useful for deserializing volume settings from a JSON object. ```APIDOC ## fromJson() ### Description Creates a VolumeSettings instance from JSON data. ### Method Factory constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **json** (`Map`) - Required - JSON object containing volume settings ### Request Example ```dart factory VolumeSettings.fromJson(Map json) ``` ### Response #### Success Response * **VolumeSettings** - The created VolumeSettings instance. #### Response Example ```dart // Example of a JSON input: { "volume": 0.8, "fadeDuration": 5000, "volumeEnforced": true } ``` ``` -------------------------------- ### Callback Type Aliases for Alarm Events Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/types.md Defines custom callback function types for when an alarm starts ringing or is stopped. These are used for internal platform communication. ```dart /// Called when an alarm starts ringing typedef AlarmRangCallback = void Function(AlarmSettings alarm); /// Called when an alarm is stopped typedef AlarmStoppedCallback = void Function(int alarmId); ``` -------------------------------- ### Configuration Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Methods and properties for configuring alarm behavior and accessing state. ```APIDOC ## Configuration ### Set Warning Notification Customizes the notification displayed when the app is killed while an alarm is active. ```dart await Alarm.setWarningNotificationOnKill(title, body); ``` ### Scheduled Alarms State Accesses the current list of scheduled alarms. ```dart Alarm.scheduled.value; ``` ### Ringing Alarms State Accesses the current list of alarms that are actively ringing. ```dart Alarm.ringing.value; ``` ``` -------------------------------- ### alarmRang Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Called by the native platform when an alarm starts ringing. It retrieves alarm settings, logs errors if settings are not found, and calls the registered alarm callback. ```APIDOC ## alarmRang() ### Description Called by the native platform when an alarm starts ringing. ### Method `Future alarmRang(int alarmId)` ### Parameters #### Path Parameters - **alarmId** (int) - Required - The ID of the alarm that started ringing ### Returns `Future` — Completes when the alarm handler is called. ### Behavior 1. Retrieves AlarmSettings for the given ID 2. Logs error if settings cannot be found 3. Calls the registered alarmRang callback with settings ### Error Handling - If alarm settings not found: logs severe error, returns without throwing - Suggests reporting issue if this occurs ### Native Call Path ``` Native code (iOS/Android) ↓ Platform channel method: "alarmRang" ↓ AlarmTriggerApiImpl.alarmRang(alarmId) ↓ Alarm.alarmRang(settings) callback ↓ Updates Alarm.ringing stream ↓ User listeners notified ``` ``` -------------------------------- ### Configure Background Modes in Info.plist Source: https://github.com/gdelataillade/alarm/blob/main/help/INSTALL-IOS.md Enables background fetch and audio capabilities for the app. Ensure these are checked in Xcode's Signing & Capabilities tab. ```xml UIBackgroundModes fetch audio ``` -------------------------------- ### Dart AlarmRang Method Signature Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md This method is called by the native platform when an alarm starts ringing. It handles retrieving alarm settings and invoking the registered callback. ```dart @override Future alarmRang(int alarmId) async ``` -------------------------------- ### Create Fixed Volume Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Use this constructor for a constant alarm volume. Optionally enforce the volume level and control system UI display. ```dart const VolumeSettings.fixed({ double? volume, bool volumeEnforced = false, bool showSystemUI = true, }) ``` -------------------------------- ### Get Current Alarm Values Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Retrieve the current state of scheduled and ringing alarms without subscribing to stream updates. This is useful for checking the current status. ```dart final currentScheduled = Alarm.scheduled.value; final currentRinging = Alarm.ringing.value; ``` -------------------------------- ### Android Recommended Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Recommended settings for Android. `androidFullScreenIntent` enables full-screen notifications, and `androidStopAlarmOnTermination` ensures clean up when the app is killed. ```dart // Recommended settings for Android AlarmSettings( // ... other settings androidFullScreenIntent: true, // Full-screen notification androidStopAlarmOnTermination: true, // Clean up on kill ) ``` -------------------------------- ### Listen to App State Changes Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/platform_timers.md Sets up a listener for app foreground/background transitions. Stores the subscription keyed by alarm ID for cleanup. ```dart static void _listenAppStateChange({ required int id, required void Function() onForeground, required void Function() onBackground, }) ``` -------------------------------- ### Check Alarm Status Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Provides examples for checking the current status of alarms, such as whether any alarms are scheduled, if a specific alarm is ringing, or retrieving all currently ringing alarms. ```dart // Check if any alarm is scheduled if (Alarm.scheduled.value.alarms.isNotEmpty) { print('At least one alarm is scheduled'); } // Check if specific alarm is ringing if (Alarm.ringing.value.containsId(42)) { print('Alarm 42 is ringing'); } // Get all ringing alarms final ringingAlarms = Alarm.ringing.value.alarms; for (final alarm in ringingAlarms) { print('Ringing: ${alarm.notificationSettings.title}'); } ``` -------------------------------- ### ensureInitialized() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Ensures the platform API listener is set up to receive calls from native code. This method instantiates the singleton if it has not already been created. Subsequent calls will have no effect as the singleton is cached. ```APIDOC ## ensureInitialized() ### Description Ensures the platform API listener is set up to receive calls from native code. Instantiates the singleton if not already created. ### Method `static void ensureInitialized({required AlarmRangCallback alarmRang, required AlarmStoppedCallback alarmStopped})` ### Parameters #### Parameters - **alarmRang** (`AlarmRangCallback`) - Required - Function to call when alarm rings - **alarmStopped** (`AlarmStoppedCallback`) - Required - Function to call when alarm stops ### Returns `void` ### Side Effects - Creates singleton instance on first call - Sets up platform channel listener - Subsequent calls do nothing (singleton is cached) ### Example (internal usage) ```dart AlarmTriggerApiImpl.ensureInitialized( alarmRang: Alarm.alarmRang, alarmStopped: Alarm._alarmStopped, ); ``` ``` -------------------------------- ### Example Usage of containsId() and removeById() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Illustrates checking for an alarm's existence using its ID and removing an alarm by its ID. The removeById() method returns a new AlarmSet. ```dart final alarmSet = AlarmSet([alarm1, alarm2]); if (alarmSet.containsId(42)) { print('Alarm with ID 42 exists'); } final originalSet = AlarmSet([alarm1, alarm2]); final newSet = originalSet.removeById(alarm1.id); print(newSet.alarms.length); // 1 ``` -------------------------------- ### Declare Project Dependencies Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md List of essential and optional dependencies for the alarm plugin. Ensure these are included in your pubspec.yaml file. ```dart collection: any equatable: ^2.0.8 flutter_fgbg: ^0.8.0 json_annotation: ^4.9.0 logging: ^1.3.0 plugin_platform_interface: ^2.1.8 rxdart: ^0.28.0 shared_preferences: ^2.5.4 ``` ```dart permission_handler: ^11.0.0 ``` -------------------------------- ### Listen for Alarm Ringing Events Source: https://github.com/gdelataillade/alarm/blob/main/README.md Subscribe to the ringing stream to execute custom logic when an alarm starts ringing. This callback receives a set of alarms that are currently ringing. ```dart Alarm.ringing.listen((AlarmSet alarmSet) { for (final alarm in alarmSet.alarms) { // yourOnRingCallback } }); ``` -------------------------------- ### Use Minimal Volume (Current System Level) Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Set `volume` to `null` to utilize the current system's volume level without modification. This is useful when you don't need to set a specific volume. ```dart final volumeSettings = VolumeSettings.fixed( volume: null, // Uses current system volume ); ``` -------------------------------- ### Configure Android App Build Gradle Source: https://github.com/gdelataillade/alarm/blob/main/help/INSTALL-ANDROID.md Ensure your app's build.gradle file includes the specified compileSdkVersion, minSdkVersion, and multiDexEnabled settings. ```Gradle android { compileSdkVersion 34 [...] defaultConfig { [...] minSdkVersion 23 // Required minimum SDK version multiDexEnabled true } } ``` -------------------------------- ### Create Staircase Fade Volume Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Use this constructor for alarms that gradually increase in volume over time in distinct steps. Define the steps with a list of VolumeFadeStep objects. Other parameters control maximum volume, enforcement, and UI. ```dart factory VolumeSettings.staircaseFade({ required List fadeSteps, double? volume, bool volumeEnforced = false, bool showSystemUI = true, }) ``` -------------------------------- ### VolumeSettings.fade() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Creates volume settings that fade the alarm audio smoothly over a specified duration. It supports setting a target volume, enforcing it, and controlling the system UI. ```APIDOC ## VolumeSettings.fade() ### Description Creates volume settings that fade the alarm audio smoothly over a duration. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Constructor Signature ```dart const VolumeSettings.fade({ required Duration fadeDuration, double? volume, bool volumeEnforced = false, bool showSystemUI = true, }) ``` ### Parameters #### Parameters - **fadeDuration** (`Duration`) - Required - Duration over which to fade the alarm from 0 to target volume. - **volume** (`double?`) - Optional - Target volume level (0.0 to 1.0). Null uses current volume. - **volumeEnforced** (`bool`) - Optional - If true, prevents user from lowering alarm volume. Defaults to `false`. - **showSystemUI** (`bool`) - Optional - If true, shows system volume UI when setting/restoring volume. Defaults to `true`. ``` -------------------------------- ### Handle Alarm API Errors Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/types.md Example of how to catch and handle specific Alarm API exceptions using the AlarmErrorCode enum. This helps in providing user-friendly feedback or taking corrective actions. ```dart try { await Alarm.set(alarmSettings: alarmSettings); } on AlarmException catch (e) { if (e.code == AlarmErrorCode.invalidArguments) { print('Invalid alarm settings: ${e.message}'); } else if (e.code == AlarmErrorCode.missingNotificationPermission) { print('Please grant notification permission'); } } ``` -------------------------------- ### Handle Missing Notification Permission Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/errors.md Provides an example of how to handle the missingNotificationPermission error. This involves requesting the necessary notification permissions from the user before attempting to set an alarm, particularly on Android 13+. ```dart import 'package:permission_handler/permission_handler.dart'; try { // Request notification permission final status = await Permission.notification.request(); if (status.isDenied) { print('Notification permission denied'); return; } // Now safe to set alarm await Alarm.set(alarmSettings: alarmSettings); } on AlarmException catch (e) { if (e.code == AlarmErrorCode.missingNotificationPermission) { print('Missing notification permission: ${e.message}'); } } ``` -------------------------------- ### VolumeFadeStep Constructor Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_fade_step.md Creates a new VolumeFadeStep instance. The time must be non-negative, and the volume must be between 0.0 and 1.0. ```APIDOC ## VolumeFadeStep Constructor ### Description Creates a volume fade step. ### Parameters #### Path Parameters - **time** (`Duration`) - Required - Time at which the volume should reach the specified level. Must be non-negative. - **volume** (`double`) - Required - Volume level at the specified time (0 = silent, 1 = maximum). Must be in [0, 1]. ``` -------------------------------- ### Serialize and Deserialize VolumeSettings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Use toJson() to serialize VolumeSettings to JSON and fromJson() to deserialize it. Ensure the VolumeSettings class is imported. ```dart // Serialize final json = volumeSettings.toJson(); // Deserialize final restored = VolumeSettings.fromJson(json); ``` -------------------------------- ### Setting Custom Notification Icon (Android) Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/notification_settings.md Example of how to set a custom notification icon for Android. Ensure the icon file is placed in the correct drawable directory and referenced by its filename without the extension. ```dart NotificationSettings( title: 'Alarm', body: 'Wake up!', icon: 'notification_icon', // refers to notification_icon.png ) ``` -------------------------------- ### Singleton Pattern Initialization Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Demonstrates the singleton pattern for AlarmTriggerApiImpl. The first call to ensureInitialized creates the instance, while subsequent calls are no-ops. This pattern ensures a single global instance is managed. ```dart // Global instance static AlarmTriggerApiImpl? _instance; // First call creates instance AlarmTriggerApiImpl.ensureInitialized(...); // Creates _instance // Subsequent calls do nothing AlarmTriggerApiImpl.ensureInitialized(...); // _instance already exists, no-op ``` -------------------------------- ### VolumeSettings.staircaseFade() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Creates volume settings with stepped volume increases over time, defined by a list of fade steps. This allows for a staircase fade effect with options for maximum volume and UI control. ```APIDOC ## VolumeSettings.staircaseFade() ### Description Creates volume settings with stepped volume increases (staircase fade) over time. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Constructor Signature ```dart factory VolumeSettings.staircaseFade({ required List fadeSteps, double? volume, bool volumeEnforced = false, bool showSystemUI = true, }) ``` ### Parameters #### Parameters - **fadeSteps** (`List`) - Required - List of fade steps defining time/volume pairs. - **volume** (`double?`) - Optional - Maximum volume level (0.0 to 1.0). - **volumeEnforced** (`bool`) - Optional - If true, prevents user from lowering alarm volume. Defaults to `false`. - **showSystemUI** (`bool`) - Optional - If true, shows system volume UI when setting/restoring volume. Defaults to `true`. ``` -------------------------------- ### Minimal Flutter App Setup and Alarm Scheduling Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/INDEX.md Initializes the Alarm plugin and schedules a basic alarm. Ensure you have initialized Flutter widgets and the Alarm plugin before running this code. The alarm is set for 8 hours from now with a fixed volume and custom notification. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Alarm.init(); runApp(const MyApp()); } // Schedule an alarm final alarmSettings = AlarmSettings( id: 1, dateTime: DateTime.now().add(Duration(hours: 8)), assetAudioPath: 'assets/alarm.mp3', volumeSettings: VolumeSettings.fixed(volume: 0.8), notificationSettings: const NotificationSettings( title: 'Good Morning', body: 'Time to wake up', ), ); await Alarm.set(alarmSettings: alarmSettings); ``` -------------------------------- ### Enabling Logging Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Provides the necessary code to enable and configure the logging system for the application. This involves setting the root log level and listening for log records to print them. ```dart import 'package:logging/logging.dart'; Logger.root.level = Level.ALL; Logger.root.onRecord.listen((record) { print('${record.loggerName}: ${record.message}'); }); ``` -------------------------------- ### Import Alarm Storage Service Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_storage.md Import the specific alarm storage service for direct access. ```dart import 'package:alarm/service/alarm_storage.dart'; ``` -------------------------------- ### Import AlarmSet Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Shows how to import AlarmSet. It is exported from the main alarm package, allowing for a direct import. ```dart import 'package:alarm/utils/alarm_set.dart'; ``` ```dart import 'package:alarm/alarm.dart'; ``` -------------------------------- ### Initialize Alarm Package and Run App Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/QUICKSTART.md Ensure the Flutter binding is initialized and the alarm package is initialized before running the main application. This is a prerequisite for using any alarm functionality. ```dart import 'package:alarm/alarm.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Alarm.init(); runApp(const MyApp()); } ``` -------------------------------- ### Import Alarm Package Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_settings.md Import the necessary Alarm package to use its functionalities. ```dart import 'package:alarm/alarm.dart'; ``` -------------------------------- ### Create and Manipulate Alarm Sets Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Demonstrates creating an AlarmSet from a list or an empty set, and immutably adding or removing alarms by ID. Use these methods to manage collections of alarms. ```dart final alarmSet = AlarmSet([alarm1, alarm2, alarm3]); final emptySet = AlarmSet.empty(); final set1 = emptySet.add(alarm1); final set2 = set1.add(alarm2); final set3 = set2.removeById(alarm1.id); if (set3.containsId(alarm2.id)) { print('Alarm 2 is still in the set'); } ``` -------------------------------- ### AlarmSet Constructors Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_set.md Initialize an AlarmSet with a collection of alarms or create an empty set. ```APIDOC ## AlarmSet() ### Description Creates an AlarmSet with the given alarms. Only one alarm per unique ID is retained. ### Parameters #### Path Parameters - **alarms** (`Iterable`) - Required - Collection of alarms to initialize the set ## AlarmSet.empty() ### Description Creates an empty AlarmSet. ### Parameters #### Path Parameters - **—** (—) - — - — ``` -------------------------------- ### Initialize Alarm Service Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/INDEX.md Initializes the alarm service. This operation does not take any parameters and returns a Future that completes when the service is ready. ```APIDOC ## Alarm.init() ### Description Initialize alarm service. ### Method `Alarm.init()` ### Parameters — ### Returns `Future` ``` -------------------------------- ### AlarmTriggerApiImpl ensureInitialized Static Method Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_trigger_api_impl.md Ensures the platform API listener is set up to receive calls from native code. It instantiates the singleton if not already created and sets up the platform channel listener. Subsequent calls have no effect as the singleton is cached. ```dart static void ensureInitialized({ required AlarmRangCallback alarmRang, required AlarmStoppedCallback alarmStopped, }) ``` ```dart AlarmTriggerApiImpl.ensureInitialized( alarmRang: Alarm.alarmRang, alarmStopped: Alarm._alarmStopped, ); ``` -------------------------------- ### Initialize Alarm Plugin Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Initializes the Alarm plugin. This must be called before using any other Alarm functionalities. ```APIDOC ## Initialize ### Description Initializes the Alarm plugin. This must be called before using any other Alarm functionalities. ### Method `async` ### Function Signature `Future init()` ### Example ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Alarm.init(); runApp(const MyApp()); } ``` ``` -------------------------------- ### Initialize Alarm Package Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/INDEX.md Ensure Flutter is initialized and then initialize the Alarm package before running your application. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); await Alarm.init(); runApp(const MyApp()); } ``` -------------------------------- ### Initialize Alarm Storage Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_storage.md Initializes the shared preferences instance and sets up foreground/background event listening. This is called automatically by `Alarm.init()` and should not need to be called manually. ```dart static Future init() ``` -------------------------------- ### Create VolumeFadeStep Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_fade_step.md Creates a single volume fade step with a specified duration and volume level. Ensure the time is non-negative and the volume is between 0.0 and 1.0. ```dart final step = VolumeFadeStep(Duration(seconds: 10), 0.5); ``` -------------------------------- ### Initialize Alarm Plugin Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/README.md Call Alarm.init() once in your main() function to ensure the plugin is properly initialized before use. ```dart // Call in main() await Alarm.init(); ``` -------------------------------- ### Create Stepped Volume Fade Settings Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_settings.md Define a volume that increases in discrete steps over time. Each step includes a duration and the target volume at that point. ```dart final volumeSettings = VolumeSettings.staircaseFade( fadeSteps: [ VolumeFadeStep(Duration.zero, 0.2), VolumeFadeStep(Duration(seconds: 5), 0.5), VolumeFadeStep(Duration(seconds: 10), 1.0), ], volume: 1.0, ); ``` -------------------------------- ### toWire Method Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/volume_fade_step.md Converts the VolumeFadeStep instance to its platform wire format, typically used for native platform communication. Duration is converted to milliseconds. ```APIDOC ## toWire() ### Description Converts to platform wire format for native platform communication. Converts Duration to milliseconds. ### Returns `VolumeFadeStepWire` ``` -------------------------------- ### AlarmSettings.copyWith() Source: https://github.com/gdelataillade/alarm/blob/main/_autodocs/api-reference/alarm_settings.md Creates a copy of the AlarmSettings instance with specified fields replaced. ```APIDOC ## copyWith() ### Description Creates a copy of this AlarmSettings with specified fields replaced. ### Method AlarmSettings copyWith({ int? id, DateTime? dateTime, String? assetAudioPath, VolumeSettings? volumeSettings, NotificationSettings? notificationSettings, bool? loopAudio, bool? vibrate, double? volume, bool? volumeEnforced, double? fadeDuration, List? fadeStopTimes, List? fadeStopVolumes, String? notificationTitle, String? notificationBody, bool? warningNotificationOnKill, bool? androidFullScreenIntent, bool? allowAlarmOverlap, bool? allowSameSecondScheduling, bool? iOSBackgroundAudio, bool? androidStopAlarmOnTermination, bool? preferConnectedAudioDevice, String? Function()? payload, }) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **id** (int?) - Optional - Fields to override. Null values keep original values - **dateTime** (DateTime?) - Optional - Fields to override. Null values keep original values - **assetAudioPath** (String?) - Optional - Fields to override. Null values keep original values - **volumeSettings** (VolumeSettings?) - Optional - Fields to override. Null values keep original values - **notificationSettings** (NotificationSettings?) - Optional - Fields to override. Null values keep original values - **loopAudio** (bool?) - Optional - Fields to override. Null values keep original values - **vibrate** (bool?) - Optional - Fields to override. Null values keep original values - **volume** (double?) - Optional - Fields to override. Null values keep original values - **volumeEnforced** (bool?) - Optional - Fields to override. Null values keep original values - **fadeDuration** (double?) - Optional - Fields to override. Null values keep original values - **fadeStopTimes** (List?) - Optional - Fields to override. Null values keep original values - **fadeStopVolumes** (List?) - Optional - Fields to override. Null values keep original values - **notificationTitle** (String?) - Optional - Fields to override. Null values keep original values - **notificationBody** (String?) - Optional - Fields to override. Null values keep original values - **warningNotificationOnKill** (bool?) - Optional - Fields to override. Null values keep original values - **androidFullScreenIntent** (bool?) - Optional - Fields to override. Null values keep original values - **allowAlarmOverlap** (bool?) - Optional - Fields to override. Null values keep original values - **allowSameSecondScheduling** (bool?) - Optional - Fields to override. Null values keep original values - **iOSBackgroundAudio** (bool?) - Optional - Fields to override. Null values keep original values - **androidStopAlarmOnTermination** (bool?) - Optional - Fields to override. Null values keep original values - **preferConnectedAudioDevice** (bool?) - Optional - Fields to override. Null values keep original values - **payload** (String? Function()?) - Optional - Fields to override. Null values keep original values ### Request Example ```dart final updated = alarmSettings.copyWith( dateTime: DateTime.now().add(Duration(hours: 1)), loopAudio: false, ); ``` ### Response #### Success Response (200) - **AlarmSettings** - New instance with updated values #### Response Example ```json { "example": "response body" } ``` ```