import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'storage_service.dart'; /// Typed boundary for non-sensitive preferences and display caches. /// /// Feature code depends on this class instead of constructing or retaining a /// [SharedPreferences] instance. class PreferencesStorage { const PreferencesStorage(this._preferences); final SharedPreferences _preferences; bool getBool(String key, {bool defaultValue = false}) => _preferences.getBool(key) ?? defaultValue; String? getString(String key) => _preferences.getString(key); bool containsKey(String key) => _preferences.containsKey(key); Future setBool(String key, bool value) => _preferences.setBool(key, value); Future setString(String key, String value) => _preferences.setString(key, value); Future remove(String key) => _preferences.remove(key); } final preferencesStorageProvider = Provider( (ref) => PreferencesStorage(StorageService.to.preferences), );