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 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, now works perfectly for a single screen, but what happens when you add a second?
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 the
PlanProvider
class so that it can handle multiple plans. Change the type ofValueNotifier
every time...