Skip to content

Object of type X is not registered inside GetIt #36

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
MatheusHoudin opened this issue Dec 20, 2019 · 8 comments
Closed

Object of type X is not registered inside GetIt #36

MatheusHoudin opened this issue Dec 20, 2019 · 8 comments

Comments

@MatheusHoudin
Copy link

Trying to create objects with get_it, although all the necessary objects are being registered as factories or lazy singletons, the library keeps saying that those objects are not registered.

final sl = GetIt.instance;

Future init() async {

sl.registerFactory(() => MoviesBloc(getMoviesWithPageUsecase: sl()));

sl.registerSingleton(() => GetMoviesWithPageUsecase(sl()));

sl.registerLazySingleton(
() => MoviesRepositoryImpl(
moviesLocalDataSource: sl(),
moviesRemoteDataSource: sl(),
networkInfo: sl()
)
);

sl.registerLazySingleton(
() => MoviesRemoteDataSourceImpl(client: sl())
);
sl.registerLazySingleton(
() => MoviesLocalDataSourceImpl(moviesBox: sl('moviesBox'))
);

sl.registerLazySingleton(
() => NetworkInfoImpl(sl())
);

final appDocumentDirectory = await path_provider.getApplicationDocumentsDirectory();
Hive.init(appDocumentDirectory.path);
final moviesBox = await Hive.openBox('movies');
sl.registerLazySingleton(() => http.Client());
sl.registerLazySingleton(() => DataConnectionChecker());
sl.registerLazySingleton(() => moviesBox,instanceName: 'moviesBox');
}

I call this method inside the main method and when I try to retrieve some object i always get the same error, example:
Invalid argument (Object of type GetMoviesWithPageUsecase is not registered inside GetIt):

@LeonanFragaLeonardo
Copy link

I have the same problem
Can you provide more information on how you solved your problem?

@mghase
Copy link

mghase commented Apr 23, 2020

i have the same issue any solution if any

@derrickxiang
Copy link

same issue here, any solution?

@escamoteur
Copy link
Collaborator

Can all that have the same problem raise a new issue with source code where you register and where you access your type?
Also check if you are on the latest version.
Even better would be a small example project where this happens because I can't reproduce it

@bvdwalt
Copy link

bvdwalt commented May 9, 2020

Hi @escamoteur, I'll open up another issue and link my github repo with my Flutter code, which is getting this error. You can then try and run the app in my repo and see if you can manage to reproduce it.
Edit: I have created the new issue #77

@yanivshaked
Copy link

I have the same issue. Using get_it from the operational flow works, but all initialization done from the test environment are lost when you invoke the application. @escamoteur Please let me know if you still need a small example project, I can prepare it ASAP.

@hmanenga
Copy link

hmanenga commented Aug 6, 2020

I have the same issue

@escamoteur
Copy link
Collaborator

all that have problems Please open a new issue with the code where you register and where you use your Objects as well as the error code.
If possible put a little repro project on Github

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

8 participants