【发布时间】:2021-01-15 17:48:35
【问题描述】:
我正在尝试根据 swapped 值返回包含 2 个小部件的列表。我试过了:
Container(child: Row(children: swapped? [a, b]: [b, a],),
其中a 和b 是Widget:
Widget a = ...
Widget b = ...
但我得到了
The operator '[]' isn't defined for the type 'bool'.
我做错了什么?
swapped 是bool
我也试过
children: swapped? List<Widget>([a, b]): List<Widget>([b, a])
得到了
The argument type 'List<Widget>' can't be assigned to the parameter type 'int'.
【问题讨论】:
-
您好,我尝试了同样的方法,它对我有用,您的错误可能是分号,您使用的是 [b:a] 而不是逗号
-
@AzadPrajapat 已编辑,这是一个错误。还是有问题