execute method
Implementation
@override
Future<Map<String, dynamic>> execute(List arguments, elementMap) async {
// Validate the keystring argument
if (arguments.length < 2 || arguments[1] is! String) {
throw ArgumentError("Invalid arguments: Key sequence string is required.");
}
String keyString = arguments[1];
ImeActionMapper.initialize();
// Handle IME actions (e.g., Enter, Next, Done)
if (ImeActionMapper.isImeAction(keyString)) {
TextInputAction? action = ImeActionMapper.toImeAction(keyString);
if (action != null) {
// Perform the action on the currently focused text field
var currentFocus = WidgetsBinding.instance.focusManager.primaryFocus?.context;
// Find the EditableTextState
EditableTextState? editableTextState =
currentFocus?.findAncestorStateOfType<EditableTextState>();
if (editableTextState != null) {
editableTextState.performAction(action);
}
} else {
throw ArgumentError("Invalid IME action: $keyString");
}
}
return {'success': true, 'key': keyString};
}