scheduleNotification method

  1. @override
Future<int> scheduleNotification({
  1. int? id,
  2. required String title,
  3. String? body,
  4. required DateTime schedule,
})
override

Schedule a notification with id, title, and body at the schedule time. If the id is not specified, a random id will be generated.

Returns the id of the notification created.

Implementation

@override
Future<int> scheduleNotification(
    {int? id,
    required String title,
    String? body,
    required DateTime schedule}) async {
  id ??= _random.nextInt(1000);
  final time =
      tz.TZDateTime.from(schedule, tz.getLocation(Settings().timezone));

  await FlutterLocalNotificationsPlugin().zonedSchedule(
    id,
    title,
    body,
    time,
    _platformChannelSpecifics,
    androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
    uiLocalNotificationDateInterpretation:
        UILocalNotificationDateInterpretation.absoluteTime,
  );

  return id;
}