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

riverpod_infinite_scroll - Filtering #240

Closed Yasser-saud closed 1 year ago

Yasser-saud commented 1 year ago

Hello,

I'm trying to implement filtering but i'm having issue refresh the API call with the new filter key

class HistoryStateNotifier extends PagedNotifier<int, Transaction> {
  Ref ref;
  String selectedFilter;

  HistoryStateNotifier({required this.ref, this.selectedFilter = 'all'})
      : super(
          load: (page, limit) => ref
              .watch(apiProvider)
              .getTransactions(page, limit, selectedFilter)
              .then((value) => value.transactions),
          nextPageKeyBuilder: NextPageKeyBuilderDefault.mysqlPagination,
        );

  void setFilter(String filter) {
    selectedFilter = filter;

    // what i'm trying to reach is when the setFilter is called, 
    //the api call should be made again with the new filter
  }
}

final historyProvider =
    StateNotifierProvider<HistoryStateNotifier, PagedState<int, Transaction>>(
  (ref) => HistoryStateNotifier(
    ref: ref,
  ),
);
clragon commented 1 year ago

It seems like you are using riverpod_infinite_scroll. The developers of that package are not related to this one. If you have issues, please ask in the riverpod_infinite_scroll repository instead.