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
612 stars 202 forks source link

Getx PagedSliverList and update itemList #272

Closed pinktoadette closed 11 months ago

pinktoadette commented 1 year ago

When moving pagingControls to GetXControllers, the pagination cannot get the new updates.

page.dart

PagedSliverList<int, MyList>.separated(
      pagingController: getController.pagingController,
      ...
)

getController.dart I have something a bit more, general idea is just updating one of the items

void update(Item item) {
 pagingController.itemList = pagingController.itemList.map((ele) {
      if (ele == item) return item; 
      return ele;
  }
}

You can see the item gets updated in pagingControllers in getX controller, but PagedSliverlist isn't wrapped with obx and shouldn't, but it can't receive changes from pagingController.

Using refresh works, but will trigger an entire page refresh and loses the placement when a user hits back, which is not desire.

Any other ways to get it update?

blackkara commented 1 year ago

just wrap this with GetX builder on the widget side

PagedSliverList<int, MyList>.separated(
      pagingController: getController.pagingController,
      ...
)

Then update your item in GetxController

item.foo = "updated"
update(); --> from GetXController