schedule method

  1. @Deprecated('Deprecated due to problems with time zones. Use zonedSchedule instead.')
Future<void> schedule(
  1. int id,
  2. String? title,
  3. String? body,
  4. DateTime scheduledDate,
  5. AndroidNotificationDetails? notificationDetails, {
  6. String? payload,
  7. bool androidAllowWhileIdle = false,
})

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

The androidAllowWhileIdle parameter determines if the notification should still be shown at the exact time when the device is in a low-power idle mode.

Implementation

@Deprecated(
    'Deprecated due to problems with time zones. Use zonedSchedule instead.')
Future<void> schedule(
  int id,
  String? title,
  String? body,
  DateTime scheduledDate,
  AndroidNotificationDetails? notificationDetails, {
  String? payload,
  bool androidAllowWhileIdle = false,
}) async {
  validateId(id);
  final Map<String, Object?> serializedPlatformSpecifics =
      notificationDetails?.toMap() ?? <String, Object>{};
  serializedPlatformSpecifics['allowWhileIdle'] = androidAllowWhileIdle;
  await _channel.invokeMethod('schedule', <String, Object?>{
    'id': id,
    'title': title,
    'body': body,
    'millisecondsSinceEpoch': scheduledDate.millisecondsSinceEpoch,
    'platformSpecifics': serializedPlatformSpecifics,
    'payload': payload ?? ''
  });
}