The setState() Method
Explore how the setState() method works in Flutter stateful widgets to manage and update UI state dynamically. Learn to implement local and parent widget state management by calling setState() properly to rebuild UI components based on user interaction.
Stateful widgets
Widgets in Flutter describe how the UI should look depending on the configuration and state. We categorize widgets into two:
- Stateless widgets: They only depend on the configurations set and do not change on user interaction.
- Stateful widgets: They depend on the configurations set and the app’s state and change on user interactions.
Stateful widgets extend the State class, where we can call the build method several times to rebuild the UI. The code snippet below shows the structure of a stateful widget.
...