// We don't have an actual instance of SharedPreferences, and we can't get one except asynchronously final sharedPreferencesProvider = Provider<SharedPreferences>((ref) => throw UnimplementedError());
Future<void> main() async { // Show a loading indicator before running the full app (optional) // The platform's loading screen will be used while awaiting if you omit this. runApp(const LoadingScreen());
// Get the instance of shared preferences final prefs = await SharedPreferences.getInstance(); return runApp( ProviderScope( overrides: [ // Override the unimplemented provider with the value gotten from the plugin sharedPreferencesProvider.overrideWithValue(prefs), ], child: const MyApp(), ), ); }