Skip to content

GetIt is not registering my Api to BloC #267

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
plibr opened this issue Mar 17, 2022 · 4 comments
Closed

GetIt is not registering my Api to BloC #267

plibr opened this issue Mar 17, 2022 · 4 comments

Comments

@plibr
Copy link

plibr commented Mar 17, 2022

here is my minimal repo: https://github.com/plibr/tutorial

I am receiving this error when I run:
E/flutter (21679): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type TutorialsApiService is not registered inside GetIt.
E/flutter (21679): (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
E/flutter (21679): Did you forget to register it?)
E/flutter (21679): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter (21679): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter (21679): #2 _GetItImplementation._findFactoryByNameAndType (package:get_it/get_it_impl.dart:372:7)
E/flutter (21679): #3 _GetItImplementation.get (package:get_it/get_it_impl.dart:393:29)
E/flutter (21679): #4 _GetItImplementation.call (package:get_it/get_it_impl.dart:430:12)
E/flutter (21679): #5 initializeDependencies (package:tutorial/src/injector.dart:31:39)
E/flutter (21679): #6 main (package:tutorial/main.dart:13:9)
E/flutter (21679): #7 _runMainZoned.. (dart:ui/hooks.dart:130:25)
E/flutter (21679): #8 _rootRun (dart:async/zone.dart:1426:13)
E/flutter (21679): #9 _CustomZone.run (dart:async/zone.dart:1328:19)
E/flutter (21679): #10 _runZoned (dart:async/zone.dart:1861:10)
E/flutter (21679): #11 runZonedGuarded (dart:async/zone.dart:1849:12)
E/flutter (21679): #12 _runMainZoned. (dart:ui/hooks.dart:126:5)
E/flutter (21679): #13 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:297:19)
E/flutter (21679): #14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
E/flutter (21679):

I injected dependencies to get_it here: https://github.com/plibr/tutorial/blob/master/lib/src/injector.dart

I don`t get any error or warning before run, but it says my TutorialsApiService is not registered to project.

Anyone can direct me to correct way?

Thanks!

@rsulab
Copy link

rsulab commented Mar 24, 2022

same problem

@plibr
Copy link
Author

plibr commented Mar 26, 2022

@rsulab have you solved this?

@plibr
Copy link
Author

plibr commented Mar 26, 2022

@escamoteur what do you think about this problem?

@plibr
Copy link
Author

plibr commented Mar 26, 2022

I found the mistake, there is another forward slash in this line:

import 'package:tutorial/src/data/datasources/remote//tutorials/tutorials_api_service.dart';
after 'remote'

Thanks!

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

3 participants