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\'.
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)
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]