Making the app state visible across multiple screens
One phrase that is thrown around a lot in the Flutter community is "Lift State Up." This mantra, which originally came from React, refers to the idea that State objects should be placed higher than the widgets that need it in the widget tree. Our InheritedWidget
, which we created in the previous recipe, works perfectly for a single screen, but it is not ideal when you add a second. The higher in the tree your state object is stored, the easier it is for your children widgets to access it.
In this recipe, you are going to add another screen to the Master Plan app so that you can create multiple plans. Accomplishing this will require our State provider to be lifted higher in the tree, closer to its root.
Getting ready
- You should have completed the previous recipes in this chapter before following along with this one.
How to do it...
Let's add a second screen to the app and lift the State higher in the tree:
- Update...