skip to Main Content

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

2

Answers


  1. I think type cast will solve your problem.

    questions[_questionIndex] as String
    

    or

    Map<String, String> instead of Map<String, Object>
    
    Login or Signup to reply.
  2. Declare questions like this

    List<Map<String, dynamic>> questions =

    instead of

    var questions =

    Access a question like this

    questions[_questionIndex]['question'] as String

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search