zonedSchedule method

  1. @override
Future<void> zonedSchedule({
  1. required int id,
  2. String? title,
  3. String? body,
  4. required TZDateTime scheduledDate,
  5. String? payload,
  6. DateTimeComponents? matchDateTimeComponents,
  7. AndroidNotificationDetails? notificationDetails,
  8. AndroidScheduleMode scheduleMode = AndroidScheduleMode.exact,
})
override

Schedules a notification to be shown at the specified date and time relative to a specific time zone.

The scheduleMode parameter defines the precision of the timing for the notification to be appear.

This will also require additional setup for the app, especially in the app's AndroidManifest.xml file. Please see check the readme for further details.

Implementation

@override
Future<void> zonedSchedule({
  required int id,
  String? title,
  String? body,
  required tz.TZDateTime scheduledDate,
  String? payload,
  DateTimeComponents? matchDateTimeComponents,
  AndroidNotificationDetails? notificationDetails,
  AndroidScheduleMode scheduleMode = AndroidScheduleMode.exact,
}) async {
  validateId(id);
  validateDateIsInTheFuture(scheduledDate, matchDateTimeComponents);

  await _channel.invokeMethod('zonedSchedule', <String, Object?>{
    'id': id,
    'title': title,
    'body': body,
    'platformSpecifics': _buildPlatformSpecifics(
      notificationDetails,
      scheduleMode,
    ),
    'payload': payload ?? '',
    ...scheduledDate.toMap(),
    if (matchDateTimeComponents != null)
      'matchDateTimeComponents': matchDateTimeComponents.index,
  });
}