如何在Dart中传播列表

TSR:

在Javascript中,我将使用传播运算符:

在此处输入图片说明

现在我对Flutter也有同样的问题:

 Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        MyHeader(),
        _buildListOfWidgetForBody(), // <- how to spread this <Widget>[] ????
        MyCustomFooter(),
      ],
    );
  }
ikben:

您现在可以从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]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章