pressEnter, hideKeyboard

in Japanese(日本語)

Fires the keyboard's commit action, or closes the on-screen keyboard.

Functions

function description
pressEnter(settle:) Fires the Enter / IME action (search, done, submit, newline …) on the currently focused input. When no field has focus, it waits up to 1.5 seconds for focus to land or the keyboard to appear, then sends Enter. If focus still has not landed, the step does not fail on iOS: Enter is sent anyway and the step gets a note saying no field had focus (the key may have gone to the field that had focus before). On Android, it fails without sending Enter when no field has input focus, or when the focused field's input connection is already closed (Flutter closes it after an Enter), because no one would receive the key; tap the field before pressing Enter again.
hideKeyboard(settle:) Closes the on-screen keyboard. Does nothing when no keyboard is showing, so it is safe to call unconditionally. On Android it presses the back key. On iOS it taps an empty spot above the keyboard (a point that is on no element, or only on a screen-wide container you cannot operate; never on text, images, buttons or input fields, a toast, or the status bar; spots right next to a button or link are tried last so as not to press it), and if no empty spot exists (a web page that fills the screen) or tapping it does not close the keyboard, it taps the Done button of the keyboard's own toolbar (the system's Previous / Next / Done bar above the keyboard that web fields show; never an app's own toolbar). Only if the keyboard is still showing does it press Enter. The next action (such as tap) waits until the screen information no longer reports the keyboard before it looks for its element (Android; on some devices the keyboard stays reported for a few seconds after it closes, hiding elements at the bottom edge).

Example

type("#search_box", "watch")
pressEnter()               // fires the field's commit action

android {
    hideKeyboard()
}

Notes