Recall & Review
beginner
What is a StatefulWidget in Flutter?
A StatefulWidget is a widget that can change its appearance over time because it holds some state information that can be updated.
Click to reveal answer
beginner
What method do you override to create the mutable state for a StatefulWidget?
You override the <code>createState()</code> method to return an instance of a State subclass that holds the widget's mutable state.Click to reveal answer
beginner
How do you update the UI when the state changes in a StatefulWidget?
You call <code>setState(() { ... })</code> inside the State class to tell Flutter to rebuild the widget with the new state.Click to reveal answer
intermediate
Why should you avoid putting mutable state inside the StatefulWidget class itself?Because the StatefulWidget is immutable; the mutable state belongs in the separate State class to keep UI and state logic separate.Click to reveal answer
intermediate
What lifecycle method is called when a StatefulWidget is first inserted into the widget tree?
The
initState() method is called once when the State object is created and inserted into the tree.Click to reveal answer
Which method must you override to create the state for a StatefulWidget?
✗ Incorrect
The createState() method returns the State object that holds the mutable state for the StatefulWidget.
What does calling setState() inside a State class do?
✗ Incorrect
setState() tells Flutter to rebuild the widget so the UI reflects the updated state.
Where should you store mutable state in a StatefulWidget?
✗ Incorrect
Mutable state belongs in the State class, not the StatefulWidget class, which is immutable.
Which lifecycle method is called only once when the State object is created?
✗ Incorrect
initState() is called once when the State object is first created.
What happens if you forget to call setState() after changing state variables?
✗ Incorrect
Without setState(), Flutter does not know to rebuild the widget, so the UI stays the same.
Explain how StatefulWidget and its State class work together to manage changing UI.
Think about how a widget can change on screen when you press a button.
You got /4 concepts.
Describe the purpose of the initState() method in the lifecycle of a StatefulWidget.
When you first open an app screen, what setup might you need?
You got /4 concepts.