admin管理员组

文章数量:1122846

creating a list view from an API pull, the there is a number of tests, from each test we test get how many answers are correct we given the students answer and the correct answer then you much say what they student got and weather they passed or failed on a list view. below is my try, it works but it makes the ui very slow to load the page. I load the full dataset into allTest map.

    ListView.builder( itemCount: No_of_tests,
    itemBuilder: (BuildContext context, int i) {
      totalAnswers = allTests['Test $i']!
          .entries
          .where(
            (element) {
              return element.value['ans'] == element.value['yourAns'];
            },
          )
          .toList()
          .length;
    results = (totalAnswers / totalquestions) * 100;
    results >= 80 ? pass = 'Passed' : pass = 'Failed';
return text('$results - $pass');
}

本文标签: