你好,我有一个包含一些数据的列表,我想在使用我的函数后按条件设置,我得到的错误类型'_CompactLinkedHashSet‘不是'Widget?’类型的一个子类型?
我不喜欢的是地位的颜色。我在哪里制造窃听器?这是我的名单
ListTile(
title: Text(model.content[index].name),
subtitle: Text("${model.content[index].status}"),
leading: status(model.content[index].status),
trailing: Icon(Icons.more_vert),
)
这就是我的功能
status(status) => {
if(status == "done"){
Icon(Icons.check_circle,
color: Colors.green)
}else if (status == "working"){
Icon(Icons.check_circle,
color: Colors.blue)
}
else{
Icon(Icons.check_circle, color: Colors.red)
}
发布于 2022-03-21 15:26:16
如果您return
status
函数中的图标,会有帮助吗?因为现在你的状态函数什么都不做。不返回也不分配。
所以,像这样:
if (status == 'done') {
return Icon(Icons.check_circle);
}
此外,在状态函数声明中有一个语法错误:
status(status) => {
...
}
应该是(在使用大括号时没有箭头函数,不像在React中所做的那样,添加了缺失的括号,添加了返回类型)。
Icon status((status) {
...
});
https://stackoverflow.com/questions/71559945
复制相似问题