enterText method Null safety
Give the text input widget specified by finder
the focus and replace its
content with text
, as if it had been provided by the onscreen keyboard.
The widget specified by finder
must be an EditableText or have
an EditableText descendant. For example find.byType(TextField)
or find.byType(TextFormField)
, or find.byType(EditableText)
.
When the returned future completes, the text input widget's text will be
exactly text
, and the caret will be placed at the end of text
.
To just give finder
the focus without entering any text,
see showKeyboard.
To enter text into other widgets (e.g. a custom widget that maintains a
TextInputConnection the way that a EditableText does), first ensure that
that widget has an open connection (e.g. by using tap to to focus it),
then call testTextInput.enterText
directly (see
TestTextInput.enterText).
Implementation
Future<void> enterText(Finder finder, String text) async {
return TestAsyncUtils.guard<void>(() async {
await showKeyboard(finder);
testTextInput.enterText(text);
await idle();
});
}