【发布时间】:2021-08-18 13:14:29
【问题描述】:
我想在颤振中过滤数据。但是,当我过滤数据时,列表的长度为零。我想根据用户的多项选择进行过滤。 这是我的代码:
列表状态 = [ '星期一', '星期二', '星期三', '星期四', '星期五', ];
Content(
title: 'Filter Days',
child: FormField<List<String>>(
// ignore: deprecated_member_use
autovalidate: true,
initialValue: appsTags,
builder: (state) {
return Column(
children: <Widget>[
Container(
alignment: Alignment.centerLeft,
child: ChipsChoice<String>.multiple(
value: state.value,
options: ChipsChoiceOption.listFrom<String,
String>(
source: status,
value: (i, v) => v,
label: (i, v) => v,
),
onChanged: (val) {
state.didChange(val);
if (this.mounted) {
setState(() {
list = apps
.where((i) => i['status'] == val
).toList();
});
}
print(list.length);
},
itemConfig: ChipsChoiceItemConfig(
selectedColor: AppColors.primaryAccentColor,
selectedBrightness: Brightness.dark,
unselectedColor:
AppColors.primaryAccentColor,
unselectedBorderOpacity: .3,
),
isWrapped: true,
),
),
],
);
},
),
),
【问题讨论】:
-
您好。与其发布完整的代码,不如只添加一个包含原始列表、过滤方式、输出内容和预期内容的最小可重现样本。
-
@NisanthReddy 好的,我会改变
-
我相信你指的是
list = apps.where(...)这一行。apps的内容是什么? -
是的,@Gpack