In short, I have three levels of ChangeNotifiers, the top level, intermediary level and bottom level. Naturally, bottom level is dependent on intermediary level and the latter dependent on the top level.
My questions are:
- Is it possible to achieve this using the Flutter Provider plugin?
- If Yes, when using the Provider plugin, is it possible to achieve this using only ChangeNotifierProvider only?
More detailed scenario
In my Flutter application, the state is logically structured in several levels. At the top, I have the Configuration
state that stores all the configurations of the app. Then, I have a DirectionState
and a LocationState
, both of which are dependent on the Configuration
state and should be notified of changes.
Then, I have my views (UIs), that is basically structured into a Stateful widget class for encoding the logic of the UI only, and a UI model class for implementing the business logic of the UI, somewhat the state of one UI only. The latter class implements the ChangeNotifier
so that the UI updates everytime its model changes. That part is pretty simple.
It becomes complex when each model's UI is dependent both on the DirectionState
and a LocationState
that is then dependent on the Configuration
state. All UI's model should be able to change the Configuration
state that should then have all effect on the entire tree. Similarly, a change in both the Direction
state and Location
state should affect all UI's model and ultimately the UI themselves.