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. NotificationDetails 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 even 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,
  NotificationDetails notificationDetails, {
  String? payload,
  bool androidAllowWhileIdle = false,
}) async {
  if (kIsWeb) {
    return;
  }
  if (defaultTargetPlatform == TargetPlatform.android) {
    await resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()!.schedule(
        id, title, body, scheduledDate, notificationDetails.android,
        payload: payload, androidAllowWhileIdle: androidAllowWhileIdle);
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    await resolvePlatformSpecificImplementation<IOSFlutterLocalNotificationsPlugin>()
        ?.schedule(id, title, body, scheduledDate, notificationDetails.iOS, payload: payload);
  } else if (defaultTargetPlatform == TargetPlatform.macOS) {
    throw UnimplementedError();
  }
}