在Javascript中,我将使用传播运算符:
现在我对Flutter也有同样的问题:
Widget build(BuildContext cont
Widget build(BuildContext context) { return Column( children: <Widget>[ MyHeader(), _buildListOfWidgetForBody(), // <- how to spread this <Widget>[] ???? MyCustomFooter(), ], ); }
您现在可以从Dart 2.3开始传播
var a = [0,1,2,3,4]; var b = [6,7,8,9]; var c = [...a,5,...b]; print(c); // prints: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]