Dear All,
I'm having troubles with the dependency injection I need to do between State objects.
To avoid to have a huge central State class that is managing everything I would like to decentralize the logic and put it in the State of the sub-components that build the UI.
In the examples of the Flutter framework that are managing interaction with external entities (HTTP, Files) the non Flutter specific objects are generally created directly from the code in the State object.
I would like to have an object which exposes services and events and to inject it into child widget States from the root widget.
The doubt I have is: how should I inject this object?
If I pass the object as a parameter to the widget, every time a build function is invoked and the widget is changed the State should unsubscribe from the events and subscribe again or at least check that the injected object is not changed every time the correlated widget changes.
I think that from a general point of view the question is: how can I send some initialization values to the State constructor / initialize?
---
Carlo BERNASCHINA
Google Intern