Summary
We learned a lot in this chapter! We observed the various types of states that an app can have and why these states should be managed. We also learned what tools and mechanisms Flutter has out of the box for managing state: starting from the basic setState
of StatefulWidget
and taking a deeper dive into Listenable
, ValueListenable
, ValueNotifier
, ChangeNotifier
, and the widgets that go with them – ValueListenableBuilder
and ListenableBuilder
. We then explored how to connect those tools with another staple Flutter widget, InheritedWidget
, and understood how it works. Finally, we reviewed the role of BuildContext
in state management and Flutter, as well as how to avoid the most common errors related to its misuse.
An important thing to note here is that to do proper state management, you already have everything in vanilla Flutter and it works perfectly fine. We have built a clean, decoupled, and maintainable solution by using only the tools that are available out of...