Skip to content

Null check operator used on a null value #321

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

Closed
rrifafauzikomara opened this issue May 5, 2023 · 2 comments
Closed

Null check operator used on a null value #321

rrifafauzikomara opened this issue May 5, 2023 · 2 comments

Comments

@rrifafauzikomara
Copy link

When I create a unit test for a class that needs a context and is also injected by get_it, I got this error.

test/main_test.dart 13:71               main.<fn>.<fn>
package:get_it/get_it_impl.dart 178:41  _ServiceFactory.getObject
package:get_it/get_it_impl.dart 434:34  _GetItImplementation.get
package:get_it/get_it_impl.dart 455:12  _GetItImplementation.call
test/main_test.dart 14:23               main.<fn>

Null check operator used on a null value

Here's the example project for the above error: https://github.com/rrifafauzikomara/flutter_sdk_example/blob/main/test/main_test.dart

@escamoteur
Copy link
Collaborator

Will have a closer look tomorrow. I checked the place of the exception and it's almost impossible, but I have to clone your project and see it myself

@escamoteur
Copy link
Collaborator

Actually the exception doesn't come from get_it.

image

your currentContext is null in your factory function.
if you enable break in all exceptions you would have found it

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