listview builder has low fps(18.7 in android simulation) when scrolling

Viewed 11

I have a fixed controller.groupedList in the form of Map<dynamic,List<Event>> and I put this into a List.builder as followings, try to get a list:

ListView.builder(
      physics: BouncingScrollPhysics(),
      controller: scrollController,
      key: _animatedKey,
      scrollDirection: Axis.vertical,
      shrinkWrap: true,
      itemCount: controller.yearOld,
      itemBuilder: (context, index) {

        var keys = controller.groupedList.keys.toList();
        var thisYearList = controller.groupedList[keys[index]];
        print('thisYearList= $thisYearList'); //it will be triggered by each pixel scrolling

        return TimelineItemWidget(
            controller: controller,
            index: index,
            thisYearList: thisYearList);
      },
    );

Now my question, it seems each pixel I scrolled, the print method is triggered, so I guess from each pixel I scroll the screen, ListView tried to run my method which transform Map<Int,List<Event>> to thisYearList, and therefore it leads to a low fps.

In the dart coding world, is there a better way to solve this issue? Thank you for your help!

0 Answers
Related