/// Thin wrapper around [SharedPreferences] for local key-value persistence. library; import 'package:shared_preferences/shared_preferences.dart'; import '../utils/constants.dart'; /// Loads and stores user preferences. Call [init] once at startup. class StorageService { StorageService({this._preferences}); SharedPreferences? _preferences; Future init() async { _preferences ??= await SharedPreferences.getInstance(); } SharedPreferences get _prefs { final prefs = _preferences; if (prefs == null) { throw StateError('StorageService.init() must be called before use.'); } return prefs; } String get themeModeName => _prefs.getString(StorageKeys.themeMode) ?? 'system'; Future setThemeModeName(String value) { return _prefs.setString(StorageKeys.themeMode, value); } bool get useRemoteData => _prefs.getBool(StorageKeys.useRemoteData) ?? false; Future setUseRemoteData(bool value) { return _prefs.setBool(StorageKeys.useRemoteData, value); } }