InfiniteQuery<T, Arg> class
InfiniteQuery caches a series of Query's for use in an infinite list.
The queryFn
must be asynchronous and the result is cached.
InfiniteQuery takes a key to identify and store it in the global cache. The key can be any serializable data. The key is converted to a String using jsonEncode.
Each InfiniteQuery can override the global defaults for refetchDuration
and cacheDuration
, see CachedQuery.config for more info.
Use revalidateAll to sequentially refetch all cached pages if the first two pages are not equal.
Use forceRevalidateAll to force the infinite query to refetch all pages when it becomes stale, rather than comparing the first page.
To run side effects if the query function is successful or not use onSuccess
and
onError
.
- Inheritance
-
- Object
- QueryBase<
List< T> , InfiniteQueryState<T> > - InfiniteQuery
Constructors
-
InfiniteQuery({required Object key, required Future<
T> queryFn(Arg arg), required GetNextArg<T, Arg> getNextArg, List<Arg> ? prefetchPages, QueryConfig? config, List<T> ? initialData, bool forceRevalidateAll = false, bool revalidateAll = false, OnQueryErrorCallback<T> ? onError, OnQuerySuccessCallback<T> ? onSuccess}) -
InfiniteQuery caches a series of Query's for use in an infinite list.
factory
Properties
- config → QueryConfig
-
The config for this specific query.
finalinherited
- forceRevalidateAll → bool
-
Whether the Query should always refetch all pages, not just check the first
for changes.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListener → bool
-
Weather the query stream has any listeners.
no setterinherited
- key → String
-
The key used to store and access the query. Encoded using jsonEncode.
finalinherited
- lastPage → T?
-
Get the last page in the InfiniteQueryState.data
no setter
-
result
→ Future<
InfiniteQueryState< T> > -
Get the result of calling the queryFn.
no setteroverride
- revalidateAll → bool
-
If the fist page has changed then revalidate all pages. Defaults to false.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stale → bool
-
Whether the current query is marked as stale and therefore requires a
refetch.
no setterinherited
-
state
→ InfiniteQueryState<
T> -
The current state of the query.
no setterinherited
-
stream
→ Stream<
InfiniteQueryState< T> > -
Stream the state of the query.
no setterinherited
- unencodedKey → Object
-
The original key.
finalinherited
Methods
-
close(
) → Future< void> -
Closes the stream and therefore starts the delete timer.
inherited
-
deleteQuery(
{bool deleteStorage = false}) → void -
Delete the query and query key from cache
inherited
-
getNextPage(
) → Future< InfiniteQueryState< T> ?> - Get the next page in an InfiniteQuery and cache the result.
-
invalidateQuery(
) → void -
Mark query as stale.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refetch(
) → Future< InfiniteQueryState< T> > -
Refetch the query immediately.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
UpdateFunc< List< updateFn) → voidT> > -
Update the current InfiniteQuery data.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited