fetch method

  1. @override
Future<List<T>> fetch({
  1. bool force = false,
})
override

Fetch or refetch data

Returns cached data immediately if available and not stale, otherwise fetches fresh data

Implementation

@override
Future<List<T>> fetch({bool force = false}) async {
  // When performing a full refresh (force=true), we reset the pagination state
  if (force) {
    _nextPageParam = initialPageParam;
    hasNextPage.value = true;
    isFetchingNextPage.value = false;
  }

  final result = await super.fetch(force: force);

  // After the initial page loads, calculate if a second page exists
  if (!isDisposed && result.isNotEmpty) {
    final nextParam = getNextPageParam(result.last, result);
    _nextPageParam = nextParam;
    hasNextPage.value = nextParam != null;
  }

  return result;
}