EdsonBueno / infinite_scroll_pagination

Flutter package to help you lazily load and display pages of items as the user scrolls down your screen.
https://pub.dev/packages/infinite_scroll_pagination
MIT License
605 stars 201 forks source link

how to remove an item #325

Closed liujian-930212 closed 2 months ago

liujian-930212 commented 2 months ago

I tried to use itemList setter to remove an item, and it seemed worked fine.

But an RangeError occurred when ‘too many items’ were removed unless refresh the whole PagedListView every time, which is laggy.

Is there a safe way to do so?

Thanks

clragon commented 2 months ago

you have to copy the list safely when removing items.

pageController.itemList = pageController.itemList.toList().where((e) => /* some condition */ );

this will correctly update the state, as we are using toList to create a new list before assigning it.