I am developing basic flutter app. The app was working fine as long as I have changed the list of questions to the key and object pairs of questions and possible answers.....Can someone please guide me how to fix it?
I have tried giving the key of the question but still the error exists.
CodePudding user response:
I think type cast will solve your problem.
questions[_questionIndex] as String
or
Map<String, String> instead of Map<String, Object>
CodePudding user response:
Declare questions like this
List<Map<String, dynamic>> questions =
instead of
var questions =
Access a question like this
questions[_questionIndex]['question'] as String