show method

Future<void> show(
  1. int id,
  2. String? title,
  3. String? body,
  4. NotificationDetails? notificationDetails, {
  5. String? payload,
})

Show a notification with an optional payload that will be passed back to the app when a notification is tapped.

Implementation

Future<void> show(
  int id,
  String? title,
  String? body,
  NotificationDetails? notificationDetails, {
  String? payload,
}) async {
  if (kIsWeb) {
    return;
  }
  if (defaultTargetPlatform == TargetPlatform.android) {
    await resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()
        ?.show(id, title, body,
            notificationDetails: notificationDetails?.android,
            payload: payload);
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    await resolvePlatformSpecificImplementation<
            IOSFlutterLocalNotificationsPlugin>()
        ?.show(id, title, body,
            notificationDetails: notificationDetails?.iOS, payload: payload);
  } else if (defaultTargetPlatform == TargetPlatform.macOS) {
    await resolvePlatformSpecificImplementation<
            MacOSFlutterLocalNotificationsPlugin>()
        ?.show(id, title, body,
            notificationDetails: notificationDetails?.macOS,
            payload: payload);
  } else if (defaultTargetPlatform == TargetPlatform.linux) {
    await resolvePlatformSpecificImplementation<
            LinuxFlutterLocalNotificationsPlugin>()
        ?.show(id, title, body,
            notificationDetails: notificationDetails?.linux,
            payload: payload);
  } else {
    await FlutterLocalNotificationsPlatform.instance.show(id, title, body);
  }
}