Home > database >  The argument type 'Map<String, Object>' can't be assigned to the parameter type
The argument type 'Map<String, Object>' can't be assigned to the parameter type

Time:01-01

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? This is the code

I have tried giving the key of the question but still the error exists.enter image description here

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

  • Related