sharedPreferences function Services
- @Riverpod(keepAlive: true)
A provider that returns an instance of SharedPreferences.
This provider is overriden in the main file to provide a synchronous instance of SharedPreferences (see the ProviderScope). For more information, see https://riverpod.dev/docs/concepts/scopes#initialization-of-synchronous-provider-for-async-apis
Currently, the provider merely returns the instance of SharedPreferences, and this is used throughout the app to store and retrieve data from the device's local storage. Alternatively, a service could be made out of this provider to handle the storage and retrieval of data in a more structured way. This would allow for better separation of concerns and more testable code, as well as avoiding writing all the key strings throughout the app.
Implementation
@Riverpod(keepAlive: true)
SharedPreferences sharedPreferences(SharedPreferencesRef ref) =>
throw UnimplementedError();