Who is this for?
iOS, Android, web, and new Flutter developers that want to understand the declarative approach to user interface development and see how to use the Provider package to manage app state in a Flutter app.
- Declarative UI development
- App state vs. local state
- Using a simple Provider
- Using a ChangeNotifier
- Adding a ChangeNotifierProvider
- Using a Consumer
Part 1: Manage State with Provider
Learn about how Flutter supports a declarative approach to building an app user interface, as opposed to the usual imperative approach used in the native SDKs.
Understand the differences between local state, best stored in StatefulWidgets, and app state that is shared across multiple widgets and screens of an app.
The Starter Project
Take a tour of the starter project code, see the use of local state in the Application class StatefulWidget, and build and run the starter project.
Set up and use your first Provider by sharing the FilmsModel data in order to show the list of films on the first screen of the app.
Create the model for your second provider, a ChangeNotifier that will be used to provide favorites data across the app.
Turn your new model into a ChangeNotifierProvider, and access the provided data to allow your user to favorite films on the app's first screen.
Use a Consumer
Build out the second screen of the app using your ChangeNotifierProvider, and see how to use a Consumer to accept data from a Provider.
Use the flutter_test package to add some simple unit tests for a model, and see where to go from here to learn more about flutter state management.