【发布时间】:2020-05-28 23:54:36
【问题描述】:
我尝试按以下代码对列表进行分组
var b = groupBy(value[index],(ABC item) => item.id);
dropDownMenuItem = buildDropDownMenuItems(b.values);
b 现在是Map<String, List<ABC>>
在buildDropDownMenuItems,我想通过List<ABC>
List<DropdownMenuItem<ABC>> buildDropDownMenuItems(List<ABC> asset) {
......
}
错误
参数类型“Iterable>”不能分配给 参数类型“列表”。
【问题讨论】:
-
你也可以添加完整的控制台日志吗?
-
@CrazyLazyCat 没有登录控制台,只是
buildDropDownMenuItems(b.values);下的一条红线。 -
好的,改成
buildDropDownMenuItems(b.values.toList()); -
@CrazyLazyCat
The argument type 'List<List<ABC>>' can't be assigned to the parameter type 'List<ABC>'.dart(argument_type_not_assignable) -
您对
Map<key, value>().values感到困惑。我觉得你必须做这样的事情buildDropDownMenuItems(b["Group Name"]);
标签: list flutter dart group-by