Mobile development

Stage 2 · Lesson 8 of 10

Form, TextFormField and validation

Widgets and layout

A Form groups TextFormField , its fields, together. A GlobalKey<FormState> lets you call validate() and save() on all of them at once. Each field takes a validator that returns an error message, or null when the text is fine.

Set keyboardType, obscureText for passwords, textInputAction to move to the next field, and autofillHints so password managers work. Use a TextEditingController when you need to read or set the text, and a FocusNode to move the focus between fields.

Scaffold makes for the keyboard by default, but the content must scroll so the field being typed in stays visible.

Common trapshowing errors on every keystroke from the first letter; autovalidateMode set to onUserInteraction is gentler.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with

  • GuideFree
    Flutter Documentation

    Google

    Do the first Flutter app codelab, then the layout, constraints and lists pages

Practise

  • Use a free challenge's mobile design image as the spec for a native screen

Keep handy

Mark this stage as not done?