setState & InheritedWidget
Grasp the basics of local state management with `setState` and understand the concept of `InheritedWidget` for passing data down the widget tree.
What is State Management?
In Flutter, 'state' refers to any data that can change during the lifetime of a widget. This could be a counter value, user input, or data fetched from the internet.
Managing this changing data, or 'state,' is crucial for building dynamic and interactive mobile applications. We need ways to update the UI when data changes.
Local State with setState
For changes that only affect a single widget, or a small, self-contained part of it, setState is your primary tool. It's used within a StatefulWidget.
Calling setState(() { ... }); tells Flutter that the internal state of this widget has changed and that it needs to rebuild its UI to reflect the new data.
All lessons in this course
- setState & InheritedWidget
- Provider Package Basics
- Riverpod for State
- BLoC Pattern with Streams