What's the usage of three dots (…) in dart List?

前端 未结 2 1320
长情又很酷
长情又很酷 2021-01-12 14:33

I have my code written like this but it gives an error saying:

Error: A value of type \'List\' can\'t be assigned to a variable of type \'Widget\'.

2条回答
  •  被撕碎了的回忆
    2021-01-12 14:48

    Dart 2.3 introduce Spread operator (…)

    Reference link : https://medium.com/flutter-community/whats-new-in-dart-2-3-1a7050e2408d

        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]
    

提交回复
热议问题