Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type 'Null' is not a subtype of type in type cast #186

Closed
mondoktamas opened this issue May 6, 2021 · 1 comment
Closed

type 'Null' is not a subtype of type in type cast #186

mondoktamas opened this issue May 6, 2021 · 1 comment

Comments

@mondoktamas
Copy link
Contributor

Hello! First of all, i would like to thank you guys for this great library :)

Today I received the below exception:

type 'Null' is not a subtype of type '{The class type i registered}' in type cast
_ServiceFactory.dispose (package:get_it/get_it_impl.dart:124:43)
_Scope.reset (package:get_it/get_it_impl.dart:286:24)
_GetItImplementation.popScope (package:get_it/get_it_impl.dart:750:5)

I have a registered lazy singleton (in my authorized scope) in the dependency tree with a dispose method, and when i call the popScope (after user logout) i receive the above exception. The case is that as i'm using a lazysingleton there is no guarantee that the object will be created, but during popping the scope the _ServiceFactory.dispose will be called, and it will try to cast a Null object to the registered type at return disposeFunction?.call(instance as T); and this causes the exception.

@escamoteur
Copy link
Collaborator

thanks for spotting. Should be fixed with V7.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants