Managing focus is a fundamental tool for creating forms with an intuitive
flow. For example, say you have a search screen with a text field.
When the user navigates to the search screen,
you can set the focus to the text field for the search term.
This allows the user to start typing as soon as the screen
is visible, without needing to manually tap the text field.

In this recipe, learn how to give the focus
to a text field as soon as it’s visible,
as well as how to give focus to a text field
when a button is tapped.

Focus a text field as soon as it’s visible

To give focus to a text field as soon as it’s visible,
use the autofocus property.

TextField

autofocus:

true

);

For more information on handling input and creating text fields,
see the Forms section of the cookbook.

Focus a text field when a button is tapped