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 doctor
flutter upgrade
Dart version (required) >= 2.3
Restart IDE (if the problem persists)