diff --git a/example/lib/screens/edit_alarm.dart b/example/lib/screens/edit_alarm.dart index 5ffa1029..9b81bb6c 100644 --- a/example/lib/screens/edit_alarm.dart +++ b/example/lib/screens/edit_alarm.dart @@ -69,12 +69,11 @@ class _ExampleAlarmEditScreenState extends State { setState(() { final DateTime now = DateTime.now(); selectedDateTime = now.copyWith( - hour: res.hour, - minute: res.minute, - second: 0, - millisecond: 0, - microsecond: 0 - ); + hour: res.hour, + minute: res.minute, + second: 0, + millisecond: 0, + microsecond: 0); if (selectedDateTime.isBefore(now)) { selectedDateTime = selectedDateTime.add(const Duration(days: 1)); } @@ -83,10 +82,16 @@ class _ExampleAlarmEditScreenState extends State { } AlarmSettings buildAlarmSettings() { + //[DO] id must be less than Android's max int value final id = creating ? DateTime.now().millisecondsSinceEpoch % 10000 : widget.alarmSettings!.id; + // [DON'T] id must be less than Android's max int value + // final id = creating + // ? DateTime.now().millisecondsSinceEpoch + // : widget.alarmSettings!.id; + final alarmSettings = AlarmSettings( id: id, dateTime: selectedDateTime, diff --git a/lib/model/alarm_settings.dart b/lib/model/alarm_settings.dart index 5673ee3d..4558d3d3 100644 --- a/lib/model/alarm_settings.dart +++ b/lib/model/alarm_settings.dart @@ -90,7 +90,9 @@ class AlarmSettings { required this.notificationBody, this.enableNotificationOnKill = true, this.androidFullScreenIntent = true, - }); + }) : assert(id != 0 && id != -1, "id cannot be set to 0 or -1"), + assert(id <= 2147483647, + "id cannot be set larger then Android Int.MAX_VALUE"); /// Constructs an `AlarmSettings` instance from the given JSON data. factory AlarmSettings.fromJson(Map json) => AlarmSettings(