import 'package:flutter/foundation.dart'; import 'persisted_setting.dart'; class AppMediaCacheLimit { static const prefKey = 'media_cache_limit_bytes'; static const int defaultValue = 500 * 1024 * 1024; // 500 МБ /// Значение «без лимита» — вытеснение из кэша отключено. static const int unlimited = 0; /// Доступные пресеты лимита, байты (0 — без лимита). static const List presets = [ 100 * 1024 * 1024, 250 * 1024 * 1024, 500 * 1024 * 1024, 1024 * 1024 * 1024, 2 * 1024 * 1024 * 1024, unlimited, ]; static final _setting = PersistedSetting( prefKey: prefKey, defaultValue: defaultValue, read: (prefs, key) => prefs.getInt(key), write: (prefs, key, value) async { await prefs.setInt(key, value); }, ); static ValueNotifier get current => _setting.current; static Future load() => _setting.load(); static Future save(int value) => _setting.save(value); }