import 'package:shared_preferences/shared_preferences.dart'; /// 自定义表情:服务端 fileId 列表。GIF / 表情面板发出的都走这里。 class StickerStore { StickerStore._(); static const _key = 'im.stickers'; static SharedPreferences? _p; static List _ids = []; static List get ids => List.unmodifiable(_ids); static Future ensure() async { _p ??= await SharedPreferences.getInstance(); _ids = _p!.getStringList(_key) ?? []; } static bool has(String fileId) => fileId.isNotEmpty && _ids.contains(fileId); static Future add(String fileId) async { if (fileId.isEmpty) return; await ensure(); if (_ids.contains(fileId)) return; _ids = [fileId, ..._ids]; await _p!.setStringList(_key, _ids); } static Future remove(String fileId) async { await ensure(); _ids = _ids.where((e) => e != fileId).toList(); await _p!.setStringList(_key, _ids); } }