useInfiniteQuery
dart/// QueryResult<List<T>> (properties only)class InfiniteQueryResult<T> {bool isFetchingNextPage;bool isFetchingPreviousPage;bool isFetchNextPageError;bool isFetchPreviousPageError;bool isRefetching;bool isRefetchError;bool hasNextPage;bool hasPreviousPage;Function? fetchNextPage;Function? fetchPreviousPage;...result}/// Prototype of useQuery (properties only)InfiniteQueryResult<T> useInfiniteQuery<T>({required int initialPageParam,int Function(T lastResult)? getNextPageParam,int Function(T firstResult)? getPreviousPageParam,...options,})
dart/// QueryResult<List<T>> (properties only)class InfiniteQueryResult<T> {bool isFetchingNextPage;bool isFetchingPreviousPage;bool isFetchNextPageError;bool isFetchPreviousPageError;bool isRefetching;bool isRefetchError;bool hasNextPage;bool hasPreviousPage;Function? fetchNextPage;Function? fetchPreviousPage;...result}/// Prototype of useQuery (properties only)InfiniteQueryResult<T> useInfiniteQuery<T>({required int initialPageParam,int Function(T lastResult)? getNextPageParam,int Function(T firstResult)? getPreviousPageParam,...options,})
Options
initialPageParam: int- Required
- The initial page index to start fetching from.
getNextPageParam: int Function(T lastResult)?- Optional
- Given the last page (and the full pages array), returns the next page param to fetch, or
null/undefinedto indicate there is no next page.
getPreviousPageParam: int Function(T firstResult)?- Optional
- Given the first page (and the full pages array), returns the previous page param to fetch, or
null/undefinedto indicate there is no previous page.
Returns (additional properties only)
data: List<T>?- Pages accumulated so far, where each entry corresponds to a single page result.
isFetchingNextPage: booltruewhile fetching the next page.
isFetchingPreviousPage: booltruewhile fetching the previous page.
isFetchNextPageError: booltruewhen the lastfetchNextPageattempt failed.
isFetchPreviousPageError: booltruewhen the lastfetchPreviousPageattempt failed.
isRefetching: booltruewhile refetching the full infinite query.
isRefetchError: booltruewhen the last refetch attempt failed.
hasNextPage: booltruewhengetNextPageParamreturns a non-null page param based on the last page.
hasPreviousPage: booltruewhengetPreviousPageParamreturns a non-null page param based on the first page.
fetchNextPage: Function?- Imperative function to trigger fetching the next page.
fetchPreviousPage: Function?- Imperative function to trigger fetching the previous page.
...result- The remaining properties are the standard
useQueryresult fields (e.g.,status,error,isFetching, etc.).
- The remaining properties are the standard
Keep in mind that imperative fetch calls, such as fetchNextPage, may interfere with default refetch behaviour. Call these functions in response to user actions when possible.