enterText method Null safety
- String text
Simulates the user changing the text of the focused text field, and resets the selection.
Calling this method replaces the content of the connected input field with
text
, and places the caret at the end of the text.
To update the UI under test after this method is invoked, use WidgetTester.pump.
This can be called even if the TestTextInput has not been registered.
If this is used to inject text when there is a real IME connection, for example when using the integration_test library, there is a risk that the real IME will become confused as to the current state of input.
See also:
- updateEditingValue, which takes a TextEditingValue so that one can also change the selection.
Implementation
void enterText(String text) {
updateEditingValue(TextEditingValue(
text: text,
selection: TextSelection.collapsed(offset: text.length),
));
}