enterText to move the caret to the end (#79506)
This commit is contained in:
@@ -166,10 +166,14 @@ class TestTextInput {
|
||||
}
|
||||
|
||||
/// Simulates the user typing the given text.
|
||||
///
|
||||
/// Calling this method replaces the content of the connected input field with
|
||||
/// `text`, and places the caret at the end of the text.
|
||||
void enterText(String text) {
|
||||
assert(isRegistered);
|
||||
updateEditingValue(TextEditingValue(
|
||||
text: text,
|
||||
selection: TextSelection.collapsed(offset: text.length),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,13 +1040,16 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
});
|
||||
}
|
||||
|
||||
/// Give the text input widget specified by [finder] the focus and
|
||||
/// enter [text] as if it been provided by the onscreen keyboard.
|
||||
/// 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].
|
||||
Future<void> enterText(Finder finder, String text) async {
|
||||
|
||||
Reference in New Issue
Block a user