enterTextByIndex method

Future<void> enterTextByIndex(
  1. String text, {
  2. required int index,
  3. String? appId,
  4. KeyboardBehavior? keyboardBehavior,
  5. Duration? timeout,
  6. Offset? tapLocation,
})

Enters text to the index-th visible text field.

If the text field at index isn't visible immediately, this method waits for the view to become visible. It prioritizes the timeout duration provided in the method call.

Native views considered to be texts fields are:

  • EditText on Android
  • TextField or SecureTextField on iOS

See also:

  • enterText, which allows for more precise specification of the text field to enter text into

appId is only used on iOS, where native queries must be scoped to a single application. If not provided, defaults to the bundle id of the app under test.

Implementation

Future<void> enterTextByIndex(
  String text, {
  required int index,
  String? appId,
  KeyboardBehavior? keyboardBehavior,
  Duration? timeout,
  Offset? tapLocation,
}) {
  return platform.action.mobile(
    android: () => platform.android.enterTextByIndex(
      text,
      index: index,
      keyboardBehavior: keyboardBehavior,
      timeout: timeout,
      tapLocation: tapLocation,
    ),
    ios: () => platform.ios.enterTextByIndex(
      text,
      index: index,
      appId: appId,
      keyboardBehavior: keyboardBehavior,
      timeout: timeout,
      tapLocation: tapLocation,
    ),
  );
}