Query<T> class
Manages the state and lifecycle of a single data query.
This class handles fetching, caching, stale-while-revalidate, retries, and background refetching.
Constructors
-
Query({required List<
Object> queryKey, required QueryFetcher<T> fetcher, required QueryCache cache, required NetworkPolicy networkPolicy, QueryConfig config = const QueryConfig(), void onSuccess()?, void onError(String error)?, void onRefreshError(String error)?}) - Creates a Query instance.
Properties
- config → QueryConfig
-
Configuration options for this specific query.
final
-
fetcher
→ QueryFetcher<
T> -
The function responsible for fetching the data.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
queryKey
→ List<
Object> -
A unique key identifying this query.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ QueryState<
T> -
Gets the current state of the query.
no setter
-
stateStream
→ Stream<
QueryState< T> > -
Exposes the stream of query state changes.
no setter
Methods
-
dispose(
) → void - Disposes the query's resources.
-
fetch(
{bool force = false}) → Future< void> - Fetches data for the query.
-
invalidate(
{bool removeCache = true}) → void - Invalidates the query, forcing a refetch on next access. Optionally removes data from cache.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refetch(
) → Future< void> - Forces a refetch of the query, bypassing cache.
-
setData(
T data) → void - Manually sets the data for this query and updates the cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited