Issue
Im trying to check users input from textFormField and check it with correct answer from list 'question_list' In this page user should input correct data to TextFormField. In for loop I'm trying to check user input from String list 'answer' and from list 'questionList'. for loop in setState() gives error
Solution
The problem is that you're trying to access an index that is greater than the list itself.
The problem is happening because you're using the list .length property. But the index of a list is zero-based (starts with zero)
Try replacing the <= for <:
for (int i = 0; i < question[0]['correct_answer'].length; i++) {
if (question[0]['correct_answer'][i] == answer[i]) {
Answered By - pedro pimont
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.