Search code examples
flutterflutter-layouttolist

Why this Widget should be returned as List?


(questionList[_questionIndex]['answers'] as List<String>).map((answer) { 
  return Answer(_textChanger, answer);
}).toList();

this code is part of my main.dart. that code is inside of Column(childer:). I want to ask why this code use "toList()"method to return as List?


Solution

  • Because Column children requires list of widgets:

    children → List The widgets below this widget in the tree. [...] final, inherited

    and toList() returns list of Answer widgets