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
629 stars 213 forks source link

UI rebuild when Change PagingState with same itemList. #233

Closed Abdktefane closed 8 months ago

Abdktefane commented 1 year ago

when change paging controller value with new PagingState instance but with the same itemList data PagingController notify the PagedListView to rebuild. we must use Deep hash and Deep equality for itemList. for example:

      final List<AdModel> localAds = _repo.getLocalAds();
      log("localAds hash: ${localAds.hashCode}"); // 224064484
      final localPagingState = PagingState(
        itemList: localAds,
        nextPageKey: null,
        error: null,
      );
      pagingController.value = localPagingState;
      log("localPagingState hash: ${localPagingState.hashCode}"); // 929420513

      final List<AdModel> remoteAds = _repo.getRemoteAds();
      log("remoteAds hash: ${remoteAds.hashCode}"); // 88481478
      final remotePagingState = PagingState(
        itemList: remoteAds,
        nextPageKey: null,
        error: null,
      );
      pagingController.value = remotePagingState;
      log("remotePagingState hash: ${remotePagingState.hashCode}"); // 804726218

      assert(localAds == remoteAds); // this will pass
      assert(localPagingState == remotePagingState); // this will fail