You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classUserStateService {
final appViewStateService =GetIt.I.get<AppViewStateService>();
}
This throws the following error
I/flutter ( 6537): Exception 'package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type AppViewStateService is not registered inside GetIt.
package:get_it/get_it_impl.dart:372
I/flutter ( 6537): (Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
This forces me to put AppViewStateService on top of UserStateService, is there no other way to do this? I tried
you have to register them in the correct sequence. registerSingletonWithDependencies is only helpful if your registration needs to wait on some async initialization of another Singleton.
Also I recommend not to store instances that are registered inside get_it in fields of other objects but always access them over GetIt.I<yourType>()
How are we supposed to do this? I'm having a hard time having services registered with
registerSingleton
depend on each other.Example
And
UserStateService
looks like thisThis throws the following error
This forces me to put
AppViewStateService
on top ofUserStateService
, is there no other way to do this? I triedBut this throws the following error
For now I'm forced to change the order of registrations, if there's another way please let me know.
The text was updated successfully, but these errors were encountered: