states_rebuilder
states_rebuilder copied to clipboard
[Question] How to work with multiple files which need to access and update the same state?
Like if I have a widget with structure
Injector(
inject: <Injectable>[Inject(() => MyState())],
builder: (context) {
ReactiveModel<MyState> myState =
Injector.getAsReactive<MyState>();
return SomeWidget(
child: ChildWidget(),
)
}
)
Where MyState can be anything but let's assume
class MyState {
String? name;
int? id;
MyState({this.name, this.id});
setName(String myName){
name = myName;
}
setId(int myId){
id = myId;
}
}
Now I want to access / update myState from ChildWidget which is in a different dart file. I could not find help on this in docs. What should be the right way to go about it?
You can check the example folders for up-to-date examples. https://github.com/GIfatahTH/states_rebuilder/tree/master/examples