enterText method

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

Enters text to the native view specified by selector.

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

The native view specified by selector must be:

  • EditText or AutoCompleteTextView on Android
  • TextField or SecureTextField on iOS

See also:

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> enterText(
  CompoundSelector selector, {
  required String text,
  String? appId,
  KeyboardBehavior? keyboardBehavior,
  Duration? timeout,
  Offset? tapLocation,
}) {
  return platform.action.mobile(
    android: () => platform.android.enterText(
      selector.android,
      text: text,
      keyboardBehavior: keyboardBehavior,
      timeout: timeout,
      tapLocation: tapLocation,
    ),
    ios: () => platform.ios.enterText(
      selector.ios,
      text: text,
      appId: appId,
      keyboardBehavior: keyboardBehavior,
      timeout: timeout,
      tapLocation: tapLocation,
    ),
    desktop: () => platform.desktop.enterText(
      text: text,
      name: selector.android.text,
      className: selector.android.className,
    ),
  );
}