setupLocator always returns void
I'm not able to use await for setupLocator. I would like the setupLocator to return a future
instead of locator.registerLazySingleton(() => SharedPreferenceService.getInstance());, it should be
locator.registerLazySingleton(() async=> await SharedPreferenceService.getInstance());
Use Presolve for registering async instance and make sure getInstance has Future return type
Presolve(
classType: LocalStorageService,
presolveUsing: LocalStorageService.getInstance,
)
I'm using presolve. getInstance returns static Future<SharedPreferenceService> getInstance()
@FilledStacks
@kodjosama
share a snippet code of the app.dart file
Using this
Presolve(
classType: CloudLoggingService,
presolveUsing: CloudLoggingService.getInstance,
),
Will generate this
Future setupLocator() async {
final sharedPreferencesService = await SharedPreferencesService.getInstance();
locator.registerSingleton(sharedPreferencesService);
}
so it's a Future you can await. We use this exact functionality