Issue
var questions = [
{
'questionText' : 'What\'s your favorite colour? ',
'answers' : [ 'Green', 'Red', 'Yellow', 'Black'],
},
];
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('My second app'),
),
body: Column(
children: [
Question(
questions[_questionIndex]['questionText'] as String
),
**questions[_questionIndex]['answers'].map((answer){
return Answer('', answer);
}),**
I tried to put "as String" but nothing worked, the compiler always returns the same error
Solution
You need to let dart know what questions[_questionIndex]['answers']
is, you can use as
to do this:
(questions[_questionIndex]['answers'] as List<String>).map((answer){
Answered By - h8moss
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.