TestTextInput class

A testing stub for the system's onscreen keyboard.

Typical app tests will not need to use this class directly.

The TestWidgetsFlutterBinding class registers a TestTextInput instance (TestWidgetsFlutterBinding.testTextInput) as a stub keyboard implementation if its TestWidgetsFlutterBinding.registerTestTextInput property returns true when a test starts, and unregisters it when the test ends (unless it ends with a failure).

See register, unregister, and isRegistered for details.

The enterText, updateEditingValue, receiveAction, and closeConnection methods can be used even when the TestTextInput is not registered. All other methods will assert if isRegistered is false.

See also:

Constructors

TestTextInput({VoidCallback? onCleared})
Create a fake keyboard backend.

Properties

editingState Map<String, dynamic>?
The last set of arguments that TextInputConnection.setEditingState sent to this stub implementation (i.e. the arguments set to TextInput.setEditingState).
getter/setter pair
hasAnyClients bool
Whether there are any active clients listening to text input.
no setter
hashCode int
The hash code for this object.
no setterinherited
isRegistered bool
Whether this TestTextInput is registered with SystemChannels.textInput.
no setter
isVisible bool
Whether the onscreen keyboard is visible to the user.
no setter
log List<MethodCall>
Log for method calls.
final
onCleared VoidCallback?
Called when the keyboard goes away.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
setClientArgs Map<String, dynamic>?
The last set of arguments supplied to the TextInput.setClient and TextInput.updateConfig methods of this stub implementation.
getter/setter pair

Methods

closeConnection() → void
Simulates the user closing the text input connection.
enterText(String text) → void
Simulates the user changing the text of the focused text field, and resets the selection.
finishScribbleInteraction() Future<void>
Simulates a scribble interaction finishing.
handleKeyboardUndo(String direction) Future<void>
Simulates iOS responding to an undo or redo gesture or button.
handleKeyDownEvent(LogicalKeyboardKey key) Future<void>
Gives text input chance to respond to unhandled key down event.
handleKeyUpEvent(LogicalKeyboardKey key) Future<void>
Gives text input chance to respond to unhandled key up event.
hide() → void
Simulates the user hiding the onscreen keyboard.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
receiveAction(TextInputAction action) Future<void>
Simulates the user pressing one of the TextInputAction buttons. Does not check that the TextInputAction performed is an acceptable one based on the inputAction setClientArgs.
register() → void
Installs this object as a mock handler for SystemChannels.textInput.
reset() → void
Resets any internal state of this object.
scribbleFocusElement(String elementIdentifier, Offset offset) Future<void>
Simulates a Scribble focus.
scribbleInsertPlaceholder() Future<void>
Simulates iOS inserting a UITextPlaceholder during a long press with the pencil.
scribbleRemovePlaceholder() Future<void>
Simulates iOS removing a UITextPlaceholder after a long press with the pencil is released.
scribbleRequestElementsInRect(Rect rect) Future<List<List>>
Simulates iOS asking for the list of Scribble elements during UIIndirectScribbleInteraction.
startScribbleInteraction() Future<void>
Simulates a scribble interaction starting.
toString() String
A string representation of this object.
inherited
unregister() → void
Removes this object as a mock handler for SystemChannels.textInput.
updateEditingValue(TextEditingValue value) → void
Simulates the user changing the TextEditingValue to the given value.

Operators

operator ==(Object other) bool
The equality operator.
inherited