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

前端 未结 2 1321
长情又很酷
长情又很酷 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:45

    I've figured out my issue. My flutter SDK wasn't upgraded. Ran flutter doctor command and sorted out the missing updates. And the syntax seems to be working fine now.

    flutter upgrade

    Dart version (required) >= 2.3

    Restart IDE (if the problem persists)

    0 讨论(0)
  • 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]
    
    0 讨论(0)
提交回复
热议问题