import 'package:flutter/foundation.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SettingsService extends ChangeNotifier { late final SharedPreferences _prefs; var _initialized = false; SettingsService(); var _lowBandwidthMode = false; bool get lowBandwidthMode => _lowBandwidthMode; set lowBandwidthMode(bool value) { _lowBandwidthMode = value; _prefs.setBool(_lowBandwidthModeKey, _lowBandwidthMode); notifyListeners(); } Future initialize() async { if (_initialized) { return; } _prefs = await SharedPreferences.getInstance(); _lowBandwidthMode = _prefs.getBool(_lowBandwidthModeKey) ?? false; _initialized = true; } } const _lowBandwidthModeKey = 'LowBandwidthMode';