Closed
Description
I pop scope on widget dispose and register a new singleton on a new screen open.
But the new singleton gets into the old scope which would got disposed in a next frame. That's because of screens transitions which has not finished, thus old screen's dispose function has called a bit later than new screen's initState.
I couldn't figure out for a long time why my new singleton disappears!
Proposal:
GetIt.pushNewScope()
and GetIt.popScope()
shouldn't be imperative.
Force user to register singletons inside of pushNewScope callback
var profileScope = GetIt.pushNewScope(init: (getIt) {
getIt.registerSingleton(EditProfileController());
})
GetIt.I.registerSingleton(YetAnotherController()); // does not get into the scope above
User should pop scope only by name or by instance:
profileScope.pop();
// or
GetIt.popScope(profileScope);
// or
GetIt.popScope(name: 'profile');
Metadata
Metadata
Assignees
Labels
No labels