showNotification method

  1. @override
Future<int> showNotification({
  1. int? id,
  2. required String title,
  3. required String message,
  4. String? channelId,
  5. NotificationImportance? importance,
  6. bool? autoCancel,
  7. String? targetScreen,
  8. Map<String, dynamic>? extraData,
})
override

Show a simple notification.

Returns the notification ID.

Implementation

@override
Future<int> showNotification({
  int? id,
  required String title,
  required String message,
  String? channelId,
  NotificationImportance? importance,
  bool? autoCancel,
  String? targetScreen,
  Map<String, dynamic>? extraData,
}) async {
  final result = await methodChannel.invokeMethod<int>('showNotification', {
    if (id != null) 'id': id,
    'title': title,
    'message': message,
    if (channelId != null) 'channelId': channelId,
    if (importance != null) 'priority': importance.value,
    if (autoCancel != null) 'autoCancel': autoCancel,
    if (targetScreen != null) 'targetScreen': targetScreen,
    if (extraData != null) 'extraData': extraData,
  });
  return result ?? -1;
}