I have two services to register. One is LocationService and another is HomeViewModel. HomeViewModel depends on initialization of LocationService. But right now I am getting this error:
Unhandled Exception: Bad state: This instance of the type LocationService is not available in GetIt If you have registered it as LazySingleton, are you sure you have used it at least once?
Here's how I am registering them:
setupLocators(){
getIt.registerSingletonAsync<LocationService>(() async {
final locationService = LocationService();
await locationService.init();
return locationService;
}, signalsReady: true);
getIt.registerSingletonAsync<HomeViewModel>(()async => HomeViewModel(),
dependsOn: [LocationService]);
}
What am I doing wrong?