InfiniteQuerySelectOptions<TPageData, TPageParam, TData> class
final
Observer options for an infinite query whose observers see a projection
of the pages: select is required and anchors TData.
InfiniteQuerySelectOptions<List<Post>, int, List<Post>> flatFeed() =>
InfiniteQuerySelectOptions<List<Post>, int, List<Post>>(
queryKey: QueryKey(['feed']),
pageFn: (context) => api.feed(cursor: context.pageParam),
initialPageParam: 0,
getNextPageParam: (page, pages, pageParam, pageParams) =>
page.isEmpty ? null : pageParam + page.length,
select: (data) => [for (final page in data.pages) ...page],
);
- Inheritance
-
- Object
- QueryOptions<
InfiniteData< TPageData, TPageParam> > - InfiniteQueryOptions<
TPageData, TPageParam> - InfiniteQueryObserverOptionsBase<
TPageData, TPageParam, TData> - InfiniteQuerySelectOptions
- Annotations
Constructors
-
InfiniteQuerySelectOptions({required QueryKey queryKey, required InfinitePageFn<
TPageData, TPageParam> pageFn, required TPageParam initialPageParam, required PageParamFn<TPageData, TPageParam> getNextPageParam, required SelectFn<InfiniteData< select, PageParamFn<TPageData, TPageParam> , TData>TPageData, TPageParam> ? getPreviousPageParam, int? maxPages, Enabled? enabled, StaleTime? staleTime, GcTime? gcTime, RetryPolicy? retry, RetryDelay? retryDelay, NetworkMode? networkMode, InitialData<InfiniteData< ? initialData, DateTime? initialDataUpdatedAt, DateTime? initialDataUpdatedAtCompute()?, StructuralSharing<TPageData, TPageParam> >InfiniteData< ? structuralSharing, Object? meta, PlaceholderData<TPageData, TPageParam> >InfiniteData< ? placeholderData, RefetchOn? refetchOnMount, RefetchOn? refetchOnWindowFocus, RefetchOn? refetchOnReconnect, RefetchInterval? refetchInterval, bool? refetchIntervalInBackground, bool? retryOnMount})TPageData, TPageParam> > -
The paging fields, the cache-layer options, and the observer's own,
selectrequired.const
Properties
- enabled → Enabled?
-
Whether the query may fetch on its own. The default: Enabled.yes. A
disabled query still serves whatever the cache holds and can still be
refetched by hand.
finalinherited
- gcTime → GcTime?
-
How long the query stays cached after its last observer leaves. The
default: GcTime.defaultValue, five minutes.
finalinherited
-
getNextPageParam
→ PageParamFn<
TPageData, TPageParam> -
Given the last page, the param for the one after it, or
nullwhen there is none. Required.finalinherited -
getPreviousPageParam
→ PageParamFn<
TPageData, TPageParam> ? -
Given the first page, the param for the one before it, or
nullwhen there is none. Default: none — unset,hasPreviousPageis always false and a previous-page fetch fetches nothing.finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
initialData
→ InitialData<
InfiniteData< ?TPageData, TPageParam> > -
Data the cache starts with, as if it had been fetched — see
InitialData. No default: unset, the query starts without data. Unlike
placeholderDatait is written to the cache, and it goes stale by staleTime from initialDataUpdatedAt on.finalinherited - initialDataUpdatedAt → DateTime?
-
When initialData was fetched, for the staleness clock. No default:
unset, the seed counts as fetched the moment it is written.
finalinherited
- initialDataUpdatedAtCompute → DateTime? Function()?
-
Computes the seed timestamp only when data is actually seeded. No
default. Mutually exclusive with initialDataUpdatedAt; a
nullresult means now.finalinherited - initialPageParam → TPageParam
-
The param the first page is fetched with. Required; there is no
default.
finalinherited
- maxPages → int?
-
How many pages to keep at most. Default: unset, which keeps every page;
0also keeps every page.finalinherited - meta → Object?
-
Arbitrary data carried along for logging, devtools or a query function,
which receives it as QueryFunctionContext.meta. No default: unset,
the key's registered default applies, if any.
finalinherited
- networkMode → NetworkMode?
-
How connectivity gates the fetch. The default: NetworkMode.online,
an offline device pauses the fetch until it is back.
finalinherited
-
pageFn
→ InfinitePageFn<
TPageData, TPageParam> -
Fetches one page, given its param and direction. Required.
finalinherited
- pages → int?
-
How many pages to fetch up front — used to warm a cache with several
pages, or to refetch a fixed number of them. Default: unset, which
fetches one page into an empty query and refetches as many pages as
the query already holds.
finalinherited
-
placeholderData
→ PlaceholderData<
InfiniteData< ?TPageData, TPageParam> > -
Pages shown while the query has none of its own, as an InfiniteData;
never written to the cache. Default: none. See
QueryObserverOptionsBase.placeholderData.
finalinherited
-
queryFn
→ QueryFn<
InfiniteData< ?TPageData, TPageParam> > -
Fetches the data. Unset, the query uses the function registered for its
key with QueryClient.setQueryDefaults; with none there either, a
fetch fails with MissingQueryFunctionError.
finalinherited
- queryKey → QueryKey
-
The key this query is cached under. Required. Bound to exactly one data
type: a key read as another type — a supertype included — throws
QueryDataTypeError.finalinherited - refetchInterval → RefetchInterval?
-
Polls the query on a timer while this observer is subscribed. Default
RefetchInterval.off. Each poll re-requests every held page, first to
last — mind the cost with many pages. See
QueryObserverOptionsBase.refetchInterval.
finalinherited
- refetchIntervalInBackground → bool?
-
Whether refetchInterval keeps polling while the app is not focused.
Default
false. See QueryObserverOptionsBase.refetchIntervalInBackground.finalinherited - refetchOnMount → RefetchOn?
-
Whether this observer subscribing triggers a refetch. Default
RefetchOn.ifStale. A refetch re-requests every held page, first to
last. See QueryObserverOptionsBase.refetchOnMount.
finalinherited
- refetchOnReconnect → RefetchOn?
-
Whether the device coming back online triggers a refetch. Default
RefetchOn.ifStale (RefetchOn.never under NetworkMode.always). A
refetch re-requests every held page, first to last. See
QueryObserverOptionsBase.refetchOnReconnect.
finalinherited
- refetchOnWindowFocus → RefetchOn?
-
Whether the app regaining focus triggers a refetch. Default
RefetchOn.ifStale. A refetch re-requests every held page, first to
last. See QueryObserverOptionsBase.refetchOnWindowFocus.
finalinherited
- retry → RetryPolicy?
-
Whether a failed fetch is retried. The default:
RetryPolicy.times(3), three retries after the first failure (TanStack Query:retry: 3). QueryClient.query is the exception: when neither these options nor the client's defaults set retry, its fetch is not retried.finalinherited - retryDelay → RetryDelay?
-
How long to wait between attempts. The default:
RetryDelay.defaultValue, exponential back-off from one second —
one, two, four, … — capped at thirty.
finalinherited
- retryOnMount → bool?
-
Whether a query that ended in an error is fetched again when an
observer subscribes. Default
true. See QueryObserverOptionsBase.retryOnMount.finalinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
select
→ SelectFn<
InfiniteData< TPageData, TPageParam> , TData> -
QuerySelectOptions.select, over the whole InfiniteData — the place
to flatten pages into one list.
final
- staleTime → StaleTime?
-
How long fetched data counts as fresh. The default: StaleTime.zero,
stale the moment it arrives, so every mount, focus and reconnect
refetches.
finalinherited
-
structuralSharing
→ StructuralSharing<
InfiniteData< ?TPageData, TPageParam> > -
How new data is reconciled with what the cache already holds — see
StructuralSharing. The default:
replaceEqualDeep, which keeps every deep-equal part of the previous data. noStructuralSharing turns it off.finalinherited -
toStringFields
→ Map<
String, Object?> -
QueryOptions.toStringFields minus the derived
behaviorandqueryFn, plus the paging fields.no setterinherited
Methods
-
copyWith(
{QueryKey? queryKey, QueryFn< InfiniteData< ? queryFn, Enabled? enabled, StaleTime? staleTime, GcTime? gcTime, RetryPolicy? retry, RetryDelay? retryDelay, NetworkMode? networkMode, InitialData<TPageData, TPageParam> >InfiniteData< ? initialData, DateTime? initialDataUpdatedAt, DateTime? initialDataUpdatedAtCompute()?, StructuralSharing<TPageData, TPageParam> >InfiniteData< ? structuralSharing, Object? meta, InfinitePageFn<TPageData, TPageParam> >TPageData, TPageParam> ? pageFn, TPageParam? initialPageParam, PageParamFn<TPageData, TPageParam> ? getNextPageParam, PageParamFn<TPageData, TPageParam> ? getPreviousPageParam, int? maxPages, int? pages, PlaceholderData<InfiniteData< ? placeholderData, RefetchOn? refetchOnMount, RefetchOn? refetchOnWindowFocus, RefetchOn? refetchOnReconnect, RefetchInterval? refetchInterval, bool? refetchIntervalInBackground, bool? retryOnMount, SelectFn<TPageData, TPageParam> >InfiniteData< ? select}) → InfiniteQuerySelectOptions<TPageData, TPageParam> , TData>TPageData, TPageParam, TData> -
This, with the given fields replaced, observer half included; each
shape returns its own type, and only InfiniteQuerySelectOptions.copyWith
accepts a
select.pagesis not accepted either: see InfiniteQueryOptions.pages.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited