Flutter Decoded.
esc

Type to search lessons, steps and concepts.

↑ ↓ move · ↵ open · esc close
Support
Language
Made with ♥ by Aman Singh · Support the projectNot affiliated with Google. Flutter and Dart are trademarks of Google LLC. Videos belong to their creators.
Course46 lessons
›01. Dart Foundations0/4
  1. Variables, Types & Null Safety
  2. Functions & Classes
  3. Futures, async/await & Streams
  4. Records, Patterns & Sealed Classes
›02. Flutter Fundamentals0/4
  1. Everything Is a Widget
  2. Stateless vs Stateful Widgets
  3. Widgets, Elements & RenderObjects
  4. Project Structure & Hot Reload
›03. Layout & UI0/6
  1. Constraints Go Down, Sizes Go Up
  2. Rows, Columns & Flex
  3. Stack, Positioned & Layering
  4. Lists, Grids & Slivers
  5. Responsive & Adaptive Design
  6. Theming with Material 3
›04. Interaction & Navigation0/4
  1. Taps, Gestures & Input
  2. Forms & Validation
  3. Navigator & Routes
  4. go_router & Deep Links
›05. State Management0/5
  1. Ephemeral vs App State
  2. InheritedWidget & Provider
  3. Riverpod
  4. The BLoC Pattern
  5. Choosing an Approach
›06. Data & Backend0/6
  1. HTTP & JSON
  2. Dio: Interceptors & Retries
  3. Saving Data Locally
  4. Firebase: Auth & Firestore
  5. Backend Options: Supabase, Appwrite & More
  6. Isolates & Heavy Work
›07. App Architecture0/3
  1. UI Layer & Data Layer
  2. Repositories & Dependency Injection
  3. Clean Architecture & Folder Structure
›08. Motion & Performance0/4
  1. Implicit Animations
  2. Explicit Animations
  3. Custom Painting
  4. Performance & DevTools
›09. Testing & Shipping0/4
  1. Unit, Widget & Integration Tests
  2. Environments & Flavors
  3. CI/CD & Releasing
  4. Flutter on the Web & Desktop
›10. Release Automation & Code Push0/6
  1. Codemagic: Your First Pipeline
  2. Codemagic: Code Signing
  3. Codemagic: Publish to the Stores
  4. Shorebird: Code Push for Flutter
  5. Shorebird: Safe Patching
  6. Shorebird in Codemagic
Progress0 / 46
Browse all videos →
04. Interaction & Navigation / Lesson 2 / 4

Forms & Validation

Collect text input with controllers, validate fields, and submit only when everything is valid.

6 minBeginner5 steps
signup_page.dart
1final _formKey = GlobalKey<FormState>();
2final _email = TextEditingController();
3
4Form(
5 key: _formKey,
6 child: Column(children: [
7 TextFormField(
8 controller: _email,
9 decoration: const InputDecoration(labelText: 'Email'),
10 keyboardType: TextInputType.emailAddress,
11 validator: (v) =>
12 v != null && v.contains('@') ? null : 'Enter a valid email',
13 ),
14 FilledButton(
15 onPressed: () {
16 if (_formKey.currentState!.validate()) submit(_email.text);
17 },
18 child: const Text('Sign up'),
19 ),
20 ]),
21)
22
23@override
24void dispose() {
25 _email.dispose();
26 super.dispose();
27}
Live simulatorForm + validator
iPhone 16 Pro iOS 18.2
9:41
Sign in

Submit empty to see validator errors; a valid email + 8 chars signs in.

Step 1 / 5

A Form groups fields

Form tracks every TextFormField inside it. The GlobalKey<FormState> gives you a handle to validate or reset them all at once.

You'll learn

  • Form and GlobalKey<FormState>
  • TextEditingController
  • Validators
  • Disposing controllers

Read the official docs

Build a form with validation ↗Retrieve the value of a text field ↗

Watch it built

7:03
Flutter - How To Use Form and TextFormFieldRobert Brunhage · 36K views
How I built a Flutter Forms GeneratorFilledStacks · 14K views
1 / 5
← → step · Space pause · R replay