debugBuildAlertPayload function

  1. @visibleForTesting
Map<String, Object?> debugBuildAlertPayload({
  1. required List<CNAlertAction<Object?>> actions,
  2. String? title,
  3. String? message,
  4. List<CNAlertTextField> textFields = const <CNAlertTextField>[],
})

Builds the method channel payload for CNAlert.show.

Exposed for tests: the payload is the contract shared with CNAlertManager.swift, so it is asserted directly rather than through a platform round trip.

Implementation

@visibleForTesting
Map<String, Object?> debugBuildAlertPayload({
  required List<CNAlertAction<Object?>> actions,
  String? title,
  String? message,
  List<CNAlertTextField> textFields = const <CNAlertTextField>[],
}) {
  return <String, Object?>{
    'title': title,
    'message': message,
    'actions': [
      for (final action in actions)
        <String, Object?>{
          'label': action.label,
          'style': _styleName(action),
          'enabled': action.enabled,
          'preferred': action.isDefault,
        },
    ],
    'textFields': [
      for (final field in textFields)
        <String, Object?>{
          'placeholder': field.placeholder,
          'initialText': field.initialText,
          'obscure': field.obscureText,
        },
    ],
  };
}