Dimibe / grouped_list

A Flutter ListView in which items can be grouped into sections.
https://pub.dev/packages/grouped_list
MIT License
391 stars 107 forks source link

Ui Freezing when too many items are loaded in the list-LazyLoading feature request #179

Open RileyManda opened 1 year ago

RileyManda commented 1 year ago

I am facing an issue where my Ui freezes when i have more than 10 items in my list: I have a color generator that generates colors efficiently and never regenerates a color for the same list item saved in a map for my list. I tried removing this generator to test if the UI would stop freezing: but the UI still freezes when using grouped listview. I removed grouped listview and created a normal flutter listview. build and the Ui stopped freezing. I even tried creating separate widgets for my Ui and Data (Separation of Concerns)But all my lists that use grouped listview cause the Ui to freeze.:

This is my code snippet with GroupedListView:

 return GroupedListView(
                controller: _scrollController,
                semanticChildCount: itemList.length,
                sort: true,
                order: GroupedListOrder.ASC,
                elements: itemList,
                useStickyGroupSeparators: true,
                groupBy: (Pantry pantry) => pantry.category,

                groupHeaderBuilder: (Pantry pantry) => Padding(
                  padding: const EdgeInsets.all(10.0).copyWith(left: 20),
                  child: Text(
                    getFormattedDate(pantry.date).toUpperCase(),
                    style: const TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                      color: Colors.grey,
                    ),
                  ),
                ),
                itemBuilder: (context, Pantry pantry) {
                  return Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 8),
                    child: InkWell(
                      onTap: () {
                        textController.text = pantry.text;
                        categoryController.text = pantry.category;
                        time = pantry.time;
                        showItemInput(context, pantry: pantry);
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          color: Colors.white,
                          border: Border(
                              right: BorderSide(
                            color: getCatColorForCategory(pantry.category),
                            width: 10,
                          )),

Suggestions Please implement lazy loading to the grouped listview library