debugBuildAlertPayload function
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>[],
bool? isDark,
Map<String, Object?>? textStyle,
bool? rtl,
}) {
return <String, Object?>{
'title': title,
'message': message,
'isDark': ?isDark,
'textStyle': ?textStyle,
'rtl': ?rtl,
'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,
},
],
};
}