createNotification method

  1. @override
Future<int> createNotification({
  1. int? id,
  2. required String title,
  3. String? body,
  4. String? payload,
})
override

Create an immediate notification with id, title, and body. If the id is not specified, a random id will be generated. When tapped, payload is emitted on notificationTaps.

Returns the id of the notification created.

Implementation

@override
Future<int> createNotification({
  int? id,
  required String title,
  String? body,
  String? payload,
}) async {
  id ??= _random.nextInt(1000);
  await FlutterLocalNotificationsPlugin().show(
    id: id,
    title: title,
    body: body,
    notificationDetails: _platformChannelSpecifics,
    payload: payload,
  );
  return id;
}