0
var questions = [
    {
    "questionText":"Who created fb?", 
    "answers":["Mark Zukerberg","Bill Gates","Sundar Pichai","None"]
    },
    {
    "questionText":"What is 5+4?", 
    "answers":["9","12","1","13"]
    },
    {
    "questionText":"Who is me?", 
    "answers":["Bishal","subha","biplob","rahul"]
    }
  ];
var _questionIndex = 0;
print(questions[_questionIndex]['questionText']);

it is giving the above error

Rohan Thacker
  • 5,377
  • 3
  • 21
  • 34

1 Answers1

-1

Your code works well. However try this and let me know the result:

List<Map<String, dynamic>> questions = [
    {
    "questionText":"Who created fb?", 
    "answers":["Mark Zukerberg","Bill Gates","Sundar Pichai","None"]
    },
    {
    "questionText":"What is 5+4?", 
    "answers":["9","12","1","13"]
    },
    {
    "questionText":"Who is me?", 
    "answers":["Bishal","subha","biplob","rahul"]
    }
  ];
  
  var _questionIndex = 0;
  print(questions[_questionIndex]['questionText']);
Abbasihsn
  • 2,075
  • 1
  • 7
  • 17
  • Idk why but ur one works...even when i put dynamic instead of var it works. But still confused why var dont work – Bishal Hazarika Jun 26 '21 at 15:52
  • I am not sure, but defining variables format specifically usually works better. However, please let me know if you found the reason. – Abbasihsn Jun 26 '21 at 16:02