Stage 2 · Lesson 1 of 10
Widgets and the widget tree
In everything on screen is a : text, padding, alignment, even the whole app. Widgets are small descriptions that never change. A build method returns a widget tree of them for the current data.
A StatelessWidget depends only on what it is given. A StatefulWidget keeps a State object, which can call setState to rebuild. BuildContext is the widget's place in the tree.
You use it to look up things above it, such as Theme.of(context). This is declarative UI: you describe the screen, Flutter draws it. Learn to pull repeated parts out into their own widget classes early.
Common trapa single build method hundreds of lines deep, or extracting helper methods instead of widgets, which rebuild more than needed and cannot be const.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with
- GuideFreeFlutter Documentation
Google
Do the first Flutter app codelab, then the layout, constraints and lists pages