-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Having a way to manage scopes in Flutter.
(From https://proandroiddev.com/dagger-2-part-ii-custom-scopes-component-dependencies-subcomponents-697c1fa1cfc)
An example:
The login is implemented using multiple pages (which are managed by the Navigator). Each login page wants to access the LoginBloc, once the login is completed the LoginBloc is no longer needed and should be disposed.
Possible implementations right now:
- Nested navigators
This solves the issue as each Navigator can hold the necessary state, though this approach introduces quite a few problems because Navigators are not really intedned to be nested this way.
- Having the Bloc above the
Navigatorand only exposing them to the necessary routes
Two problems with this - nesting these dependencies can become pretty cumbersome because each route needs to be explicitly wrapped in all of the used dependencies (with dependencies I mean some kind of InheritedWidget which exposes the actual data).
And, even though other routes have no access to the data, the data is not disposed, which leads to a memory leak and leaves the bloc in an "undifined" state.
(Bloc in these examples could be replaced with any kind of business logic/ data storage)
The main problem is that each route is completely separate and there doesn't seem to be an easy way to accomplish this.
I was wondering if this is anything that should be in the framework or should be provided as a separate package.
I've talked to @rrousselGit about this, he had a few ieads how this could be solved but we'd like to hear other thoughts.
