zonedSchedule method
Future<void>
zonedSchedule(
- int id,
- String? title,
- String? body,
- TZDateTime scheduledDate,
- AndroidNotificationDetails? notificationDetails, {
- required bool androidAllowWhileIdle,
- String? payload,
- DateTimeComponents? matchDateTimeComponents,
Schedules a notification to be shown at the specified date and time relative to a specific time zone.
Implementation
Future<void> zonedSchedule(
int id,
String? title,
String? body,
TZDateTime scheduledDate,
AndroidNotificationDetails? notificationDetails, {
required bool androidAllowWhileIdle,
String? payload,
DateTimeComponents? matchDateTimeComponents,
}) async {
validateId(id);
validateDateIsInTheFuture(scheduledDate, matchDateTimeComponents);
ArgumentError.checkNotNull(androidAllowWhileIdle, 'androidAllowWhileIdle');
final Map<String, Object?> serializedPlatformSpecifics =
notificationDetails?.toMap() ?? <String, Object>{};
serializedPlatformSpecifics['allowWhileIdle'] = androidAllowWhileIdle;
await _channel.invokeMethod(
'zonedSchedule',
<String, Object?>{
'id': id,
'title': title,
'body': body,
'platformSpecifics': serializedPlatformSpecifics,
'payload': payload ?? ''
}
..addAll(scheduledDate.toMap())
..addAll(matchDateTimeComponents == null
? <String, Object>{}
: <String, Object>{
'matchDateTimeComponents': matchDateTimeComponents.index
}));
}