Module 06 of 12

State Fundamentals

Lessons

About This Module

Flutter apps are built from widgets, and every widget is either stateless or stateful. A stateless widget is a fixed description of part of the UI; a stateful widget owns data that changes over time and rebuilds when it does. Knowing which to reach for, and where that data should live, is the mental model behind every Flutter screen you'll build.

This module starts with StatelessWidget and how the widget tree and element tree relate. It then looks at ephemeral state versus app state and the idea of lifting state up so that widgets that need the same data can share it. You'll see how InheritedWidget passes data down the tree without threading it through every constructor, and finish with keys, which decide whether Flutter preserves or resets a widget's state when widgets are added, removed or reordered.

Watch the lessons in order, then continue on to State Management.

Lessons

4 videos
01

How to Create Stateless Widgets | Flutter Widgets 101 Ep. 1

The Flutter team explains what a widget is and how to compose interfaces with StatelessWidget, including how widgets and elements relate in the tree.

02

Pragmatic State Management in Flutter

A Google I/O 2019 session on thinking about state: what belongs inside a single widget, what needs to be shared, and the options for managing it.

03

How to Manage Application State Using Inherited Widgets

A Flutter team workshop on using InheritedWidget to share state with descendants in the widget tree, the mechanism that packages like Provider build on.

04

When to Use Keys | Flutter Widgets 101 Ep. 4

The Flutter team explains how keys preserve state when stateful widgets move around, and which kind of key to use.