This how I have defined my List :
final _question = [
{
'questionText': ' what\'s your favourite color?',
'answers': [
{'text': 'Black', 'score': '10'},
{'text': 'Green', 'score': '80'},
{'text': 'Blue', 'score': '147'},
{'text': 'Yellow', 'score': '60'},
]
},
{
'questionText': 'what\'s your favourite animal?',
'answers': [
{'text': 'Rabbit', 'score': '10'},
{'text': 'Tiger', 'score': '10'},
{'text': 'Elephant', 'score': '10'},
{'text': 'Lion', 'score': '10'},
]
},
];
and then I called the list to extract the 'text' and the 'Score ' by converting the map to list
Question(question[questionindex]['questionText']),
...(question[questionindex]['answers'] as List<Map<String,Object>>).map((answer) {
return Answer(() => answerQuestion(answer['Score']), answer['text']);
}).toList(),
but I got this error " The argument type 'Object?' can't be assigned to the parameter type 'String' ".