QueryClient class

The central client for managing all queries and mutations.

This class acts as a registry for Query and Mutation instances, and provides methods to interact with them (e.g., invalidate, refetch).

Constructors

QueryClient({required QueryCache cache, required NetworkPolicy networkPolicy, void onError(String error)?, void onSuccess()?, void onRefreshError(String error)?})
Creates a QueryClient instance.

Properties

cache QueryCache
final
hashCode int
The hash code for this object.
no setterinherited
networkPolicy NetworkPolicy
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes all managed queries and mutations.
getInfiniteQuery<T, PageParam>(List<Object> queryKey, InfiniteQueryFetcher<T, PageParam> fetcher, {GetNextPageParam<T, PageParam>? getNextPageParam, GetPreviousPageParam<T, PageParam>? getPreviousPageParam, QueryConfig config = const QueryConfig(), PageParam? initialPageParam}) InfiniteQuery<T, PageParam>
Retrieves or creates an InfiniteQuery instance.
getMutation<T, V>(String mutationKey, MutationFetcher<T, V> mutationFn, {MutationConfig<T, V> config = const MutationConfig()}) Mutation<T, V>
Retrieves or creates a Mutation instance.
getQuery<T>(List<Object> queryKey, Future<T> fetcher(), {QueryConfig config = const QueryConfig()}) Query<T>
Retrieves or creates a Query instance.
invalidateQueries(List<Object> queryKey) → void
Invalidates one or more queries.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyError(String error) → void
Triggers the global error listener if set
notifyRefreshError(String error) → void
Triggers the global refresh error listener if set
notifySuccess() → void
Triggers the global success listener if set
refetchQueries(List<Object> queryKey) → void
Refetches one or more queries, bypassing cache.
setOnError(void onError(String error)?) → void
Sets the global error listener
setOnRefreshError(void onRefreshError(String error)?) → void
Sets the global refresh error listener
setOnSuccess(void onSuccess()?) → void
Sets the global success listener
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited