Santhoshivan
Santhoshivan

Reputation: 43

Spread operator (...) does not work for spreading widgets from a list

I have a list of widgets which is to be spread across the children attribute of Column. Tried using the spread operator, but it gives error.

Widget build(BuildContext context) {
    return MaterialApp(
        home : Scaffold(
          appBar: AppBar(
            title: Text("My First Flutter App"),
            ),
          body: Column(
          children: [
            Question(
              questions[counter]['questionText'],
            ),
            ...(questions[counter]['answers'] as List<String>)
                .map((answer) {
              return Answer(answer,answered);
            }).toList()
          ],
        ),
      ),
    );
  }

Upvotes: 1

Views: 1362

Answers (1)

Glawin
Glawin

Reputation: 58

3 steps to follow 1)run "flutter upgrade" 2) changing the SDK in the environment in pubspec.yaml environment: sdk: ">=2.6.0 <3.0.0" OR environment: sdk: ">=2.7.0 <3.0.0" save the file

3)restart Your IDE(Visual Studio or Android Studio)

Upvotes: 3

Related Questions