I want to register the SharedPrefrences object in the get_it package to access it from all around the app and not make the main() async.
This is how I did it, But it throws an exception. Code:
appLocator.registerLazySingletonAsync<SharedPreferences>(() async {
final sh = await SharedPreferences.getInstance();
return sh;
});
Exception:
Unhandled Exception: 'package:get_it/get_it_impl.dart': Failed assertion: line 342 pos 14: 'instanceFactory.isReady': You tried to access an instance of SharedPreferences that was not ready yet
Is there a reason you don't want to make your main async? There's nothing wrong with making your main method async. It's done in the most projects you'll see.
I work as a professional Flutter Developer and use get_it and it has zero impact, so I don't see why you wouldn't.