Handle state and user interaction in Flutter — use setState and the widget lifecycle to make UIs respond to taps, gestures and text input. Learn to wire controllers, rebuild efficiently, pass data down and lift state up, and tell ephemeral state from app state.
Watch the free preview
StatelessWidget vs StatefulWidget and setState — free to watch, no account needed.
What you'll learn
- Handle state and user interaction with setState and the widget lifecycle
- Wire buttons, gestures and text controllers to update the UI
- Rebuild efficiently using const, keys and tightly scoped setState
- Pass data down with constructors and callbacks, and lift shared state up
- Distinguish ephemeral (local) state from app (shared) state and place each correctly
Syllabus
Widgets, State and setState
StatelessWidget vs StatefulWidget and setStateFree preview
The widget lifecycle — initState, build and dispose
Handling User Interaction
Buttons and callbacks
Gestures — GestureDetector and InkWell
Controllers and Efficient Rebuilds
Controllers — TextEditingController and friends
Rebuilding efficiently — const, keys and scoped setState
Sharing State Across Widgets
Passing data down — constructors and callbacks
Lifting state up; ephemeral vs app state
Lab — 10 Exercises & Solutions
Exercises 1–5
Exercises 6–10