Setting up the project
In this chapter, we will learn how to use inherited widgets by refactoring a simple Todo application. The application has an input field to create new tasks, or todos, and a list that will display todos and allow a user to either complete them or delete them.
Here is how our example should look when it is running:
Figure 3.5 – A simple Todo application
We will start with an example that shares dependencies by forwarding application data down the widget tree as properties. We will change this example to propagate those same dependencies using InheritedWidget
rather than using property forwarding. Then, we will refactor that same example to use the Provider
package, which is endorsed by the Flutter community and Google as a pragmatic solution to dependency injection and state management.
After downloading the initial application from GitHub, we can start by moving into its root directory and running the flutter pub get
command...