'Set<Row>' 类型的值不能分配给 'Widget' 类型的变量
A value of type 'Set<Row>' can't be assigned to a variable of type 'Widget'
在 运行 之后我的小部件树中:
List<List<Widget>> widgets;
/***/
Column(
children: [
for (List<Widget> range in (widgets as List<List<Widget>>)) {
Row(children: range),
}
]
)
我收到这个错误:
Error: A value of type 'Set<Row>' can't be assigned to a variable of type 'Widget'.
使用此删除{
用于 FOR 循环括号
for (List<Widget> range in (widgets as List<List<Widget>>))
Row(children: range),
Set or map? The syntax for map literals is similar to that for set
literals. Because map literals came first, {} defaults to the Map
type. If you forget the type annotation on {} or the variable it’s
assigned to, then Dart creates an object of type Map<dynamic, dynamicdart tour
提示
我们也可以这样使用
Column(children: [
...widgets.map((e) {
return Row(children: e);
}),
]);
那是因为您试图将 [[...]] 之类的东西影响到子列而不是 [],请尝试这样的东西:
Column(children: widgets.map(element) => Row(children: element));
在 运行 之后我的小部件树中:
List<List<Widget>> widgets;
/***/
Column(
children: [
for (List<Widget> range in (widgets as List<List<Widget>>)) {
Row(children: range),
}
]
)
我收到这个错误:
Error: A value of type 'Set<Row>' can't be assigned to a variable of type 'Widget'.
使用此删除{
用于 FOR 循环括号
for (List<Widget> range in (widgets as List<List<Widget>>))
Row(children: range),
Set or map? The syntax for map literals is similar to that for set literals. Because map literals came first, {} defaults to the Map type. If you forget the type annotation on {} or the variable it’s assigned to, then Dart creates an object of type Map<dynamic, dynamicdart tour
提示
我们也可以这样使用
Column(children: [
...widgets.map((e) {
return Row(children: e);
}),
]);
那是因为您试图将 [[...]] 之类的东西影响到子列而不是 [],请尝试这样的东西:
Column(children: widgets.map(element) => Row(children: element));