I have a flutter app that use the provider package to represent state.
At the start of my app I want to run some operations and set the state of my application accordingly (when the operation are finished)
Here is what I would like to do:
class A extends ChangeNotifier {
void computute(Data data) {
...
}
...
}
class B extends ChangeNotifier {
B(){
var data = _runOperations();
_data = data.forB; // set my own state
var a = Provider.of<A>(context); // not possible
a.compute(data.forA); // notify another provider that my operations have finish and to change state accordingly
}
...
}
the issue I have here is that there is no build context so I can’t get access to other ChangeNotifier.
How to run code at the start of my flutter app and notify ChangeNotifier accordingly when the operation is finish?