问题描述
我要在单击“无”按钮时取消选择ListView的所有项目。
这是我的代码:
GridView gridItems() {
return GridView(
shrinkWrap: true,scrollDirection: Axis.vertical,physics: NeverScrollableScrollPhysics(),gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,mainAxisSpacing: 16,crossAxisSpacing: 10,childAspectRatio: 2.5),//scrollDirection: Axis.horizontal,children: List.generate(blocks.length,(index) {
return MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),side: BorderSide(color: borderGreyColor,width: 1)),//selected: paints[index].selected,child: Text(
blocks[index].title.toString(),style: TextStyle(
color: blocks[index].isSelected ? whiteColor : greyColor,fontFamily: 'PoppinsRegular',fontSize: 12),),onPressed: () {
setState(() {
blocks[index].isSelected = !blocks[index].isSelected;
if (blocks[0].isSelected == true) {
setState(() {
for (var i = 1; i < blocks.length; i++) {
blocks[i].isSelected = false;
}
});
}
//log(blocks[index].isSelected.toString());
});
},color: blocks[index].isSelected ? primaryColor : whiteColor,);
}),);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)