Closed Anfet closed 1 year ago
Same here, I just got a scope race condition, when I pop scope on widget dispose and register a new singleton on a new screen open, but it gots disposed in a several milliseconds. I think I'll file a new issue.
Any idea how this should lool like? If you only want to tie a scope to a widgets life cycle, the get_it_mixin would be the more elegant solution.
Just add a scope name to close function.
Can you elaborate on how you mean that?
Just add a scopeName to popScope function.
getIt.pushNewScope(scopeName: someScreen);
getIt.popScope(scopeName: someScreen);
This way we can close any open scope.
but that wouldn't be popping but removing a scope anywhere in the stack, or not?
There is actually a PR waiting for that https://github.com/fluttercommunity/get_it/pull/292
I'm not sure if that would help with the race condition that you observed?
Yep. Thats exactly what is needed. Thank you.
Hi everyone.
With this feature we can tie scopes to stateful widget lifecycle initState/dispose methods.
With current model it's not possible, since widget A can be disposed after Widget B initState is called. Therefor breaking scope destruction.