/// 屏蔽的分类 import 'package:event/event.dart'; import 'package:flutter/material.dart'; import 'package:multi_select_flutter/dialog/mult_select_dialog.dart'; import 'package:multi_select_flutter/multi_select_flutter.dart'; import '../Method.dart'; import '../store/Categories.dart'; late List shadowCategories; var shadowCategoriesEvent = Event(); Future initShadowCategories() async { shadowCategories = await method.getShadowCategories(); } Future chooseShadowCategories(BuildContext context) async { await showDialog( context: context, builder: (ctx) { var initialValue = []; shadowCategories.forEach((element) { if (shadowCategories.contains(element)) { initialValue.add(element); } }); return MultiSelectDialog( title: Text('封印'), searchHint: '搜索', cancelText: Text('取消'), confirmText: Text('确定'), items: storedCategories.map((e) => MultiSelectItem(e, e)).toList(), initialValue: initialValue, onConfirm: (List? value) async { if (value != null) { await method.setShadowCategories(value); shadowCategories = value; shadowCategoriesEvent.broadcast(); } }, ); }, ); } Widget shadowCategoriesActionButton(BuildContext context) { return IconButton( onPressed: () { chooseShadowCategories(context); }, icon: Icon(Icons.dnd_forwardslash), ); }