showNotificationWithActions method

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

Show a notification with custom actions.

Each action is a map with 'title' and 'route' keys. Returns the notification ID.

Implementation

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