-
-
Notifications
You must be signed in to change notification settings - Fork 153
How to use registerFactory ? #101
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
Comments
From the code above this seems a bit strange to me. I always recomment passing the Generic type when you use What I don't understand is this here: sl.registerFactory<UserRepository>(
() => UserSummaryRepositoryImpl()); where you use a complete different Implementation than the one in your error Message. |
@escamoteur hello sir
|
you mixed up async registration and sync call of your function must look like static _registerDatabase() async {
AppDatabase database =
await $FloorAppDatabase.databaseBuilder('test.db').build();
sl.registerLazySingleton(() => database.userDao);
} |
@escamoteur thank you. It worked. Can you help me with this question? I'm android developer. I used https://github.com/InsertKoinIO/koin to inject function.
But for get_it. I need to do the following sl.registerSingleton(UserRepositoryImpl()); =====> So for get_it. Is there a way to do the same as koin ?. Please help me. Thank you very much. |
What are you trying to do there? sl.registerSingleton<UserRepository>(UserRepositoryImpl()); |
@escamoteur Thank you very much. It worked. |
@escamoteur When I add UserDao inside UserRepositoryImpl. It show error. I use like below
This is error
Please help me. thank you very much. |
You never registered a type `UserRepository´ in your code. You only registered a derived class. If you would always use the generic types that would not happen to you. Instead of sl.registerSingleton(UserManager()); you have to do sl.registerSingleton<UserRepository>(UserManager()); |
Uh oh!
There was an error while loading. Please reload this page.
Hello
I have 2 class
I use like below
on main.dart
And get error below
NOTE: If I use the following then it works. But it is not clear.
Please help me solve the above case. thank you very much
The text was updated successfully, but these errors were encountered: