zenquery library

The entry point for the ZenQuery package.

ZenQuery provides a set of tools for managing server state in Flutter applications, leveraging the power of Riverpod. It offers a simple and consistent API for handling queries, mutations, and infinite pagination.

To use ZenQuery, simply import this library:

import 'package:zenquery/zenquery.dart';

Classes

AnyNotifier<StateT, ValueT> Notifiers
A base class for all "notifiers".
AsyncData<ValueT> Core
Creates an AsyncValue with a data.
AsyncError<ValueT> Core
Creates an AsyncValue in the error state.
AsyncLoading<ValueT> Core
Creates an AsyncValue in loading state.
AsyncNotifier<StateT> Notifiers
A Notifier implementation that is asynchronously initialized.
AsyncNotifierProvider<NotifierT extends AsyncNotifier<ValueT>, ValueT> Providers
A provider which creates and listen to an AsyncNotifier.
AsyncProviderListenable<ValueT>
A ProviderListenable that exposes an AsyncValue and can be converted into a Future using the future property.
AsyncResult<ValueT>
A variant of AsyncValue that excludes AsyncLoading.
AsyncValue<ValueT> Core
A utility for safely manipulating asynchronous data.
Family
A base class for all families
FutureProvider<ValueT> Providers
A provider that asynchronously creates a value.
FutureProviderFamily<ValueT, ArgT>
The Family of a FutureProvider
InfinityQuery<T, TCursor>
Manages the state and logic for infinite pagination.
InfinityQueryData<T, C>
Holds the state and actions for an infinite query.
A object that maintains a provider alive.
Mutation<ResultT>
Mutations are a form of UI state that represents "side-effects" (such as "submitting a form" or "saving a file", etc).
MutationAction<T>
Encapsulate a mutation's state and actions.
MutationActionWithParam<T, TParam>
Encapsulate a mutation's state and actions, expecting a parameter.
MutationError<ResultT>
The mutation has failed with an error.
MutationIdle<ResultT>
The mutation is not running.
MutationPending<ResultT>
The mutation has been called and is in progress.
MutationState<ResultT>
The current state of a mutation.
MutationSuccess<ResultT>
The mutation has completed successfully.
MutationTarget
An interface for objects that can be passed to Mutation.run.
MutationTransaction
A "ref" to be used within Mutation.run.
Notifier<ValueT> Notifiers
A class which exposes a state that can change over time.
NotifierProvider<NotifierT extends Notifier<ValueT>, ValueT> Providers
A provider that exposes a synchronous Notifier.
NotifierProviderFamily<NotifierT extends Notifier<StateT>, StateT, ArgT>
The Family of NotifierProvider.
Override
An object used by ProviderContainer/ProviderScope to override the behavior of a provider/family for part of the application.
Provider<ValueT> Providers
A provider that exposes a read-only value.
ProviderBase<StateT>
A base class for all providers.
ProviderContainer Core
An object that stores the state of the providers and allows overriding the behavior of a specific provider.
ProviderFamily<StateT, ArgT>
The Family of Provider
ProviderListenable<StateT>
A base class for all providers, used to consume a provider.
ProviderListenableOrFamily
A shared interface between ProviderListenable and Family.
ProviderObserver Core
An object that listens to the changes of a ProviderContainer.
ProviderObserverContext Core
Information about the ProviderObserver event.
ProviderOrFamily
A common interface shared by ProviderBase and Family
ProviderSubscription<OutT> Core
Represents the subscription to a ProviderListenable.
ProviderTransformer<InT, ValueT>
The logic responsible for transforming a ProviderListenable into another ProviderListenable.
ProviderTransformerContext<InT, OutT>
An object containing metadata about the listened object of a ProviderTransformer.
QueryEditable<NResult>
An AsyncNotifier that allows manual modification of its state.
QueryEditableFamily<NResult, NParam>
An AsyncNotifier for a family of editable queries.
Ref Core
An object used by providers to interact with other providers and the life-cycles of the application.
Refreshable<StateT>
An interface for provider expressions that can be passed to ref.refresh
StreamNotifier<ValueT> Notifiers
A variant of AsyncNotifier which has build creating a Stream.
StreamNotifierProvider<NotifierT extends StreamNotifier<ValueT>, ValueT> Providers
A provider which creates and listen to an StreamNotifier.
StreamNotifierProviderFamily<NotifierT extends StreamNotifier<ValueT>, ValueT, ArgT>
The Family of StreamNotifierProvider.
StreamProvider<ValueT> Providers
Creates a stream and exposes its latest event.
StreamProviderFamily<ValueT, ArgT>
The Family of a StreamProvider

Mixins

SyncProviderTransformerMixin<InT, ValueT>
A mixin for custom ProviderListenables that do not emit AsyncValue.

Extensions

AsyncValueExtensions on AsyncValue<ValueT>
Adds non-state related methods/getters to AsyncValue.
ProviderListenableSelect on ProviderListenable<InT>
Adds select to ProviderListenable.

Functions

createInfinityQuery<T, TCursor>({required FetchFunction<T, TCursor> fetch, required NextCursorFunction<T, TCursor> getNextCursor}) Provider<InfinityQueryData<T, TCursor>>
Creates a Provider for an InfinityQueryData that automatically disposes when unused.
createInfinityQueryPersist<T, TCursor>({required FetchFunction<T, TCursor> fetch, required NextCursorFunction<T, TCursor> getNextCursor}) Provider<InfinityQueryData<T, TCursor>>
Creates a Provider for an InfinityQueryData that persists its state.
createMutation<T>(Future<T> action(MutationTransaction tsx)) Provider<MutationAction<T>>
Creates a Provider for a MutationAction that automatically disposes when unused.
createMutationPersist<T>(Future<T> action(MutationTransaction tsx)) Provider<MutationAction<T>>
Creates a Provider for a MutationAction that persists its state.
createMutationWithParam<T, TParam>(Future<T> action(MutationTransaction tsx, TParam payload)) Provider<MutationActionWithParam<T, TParam>>
Creates a Provider for a MutationActionWithParam that automatically disposes when unused.
createMutationWithParamPersist<T, TParam>(Future<T> action(MutationTransaction tsx, TParam payload)) Provider<MutationActionWithParam<T, TParam>>
Creates a Provider for a MutationActionWithParam that persists its state.
createQuery<T>(Future<T> query(Ref ref)) FutureProvider<T>
Creates a FutureProvider that automatically disposes of its state when listener count reaches zero.
createQueryEditable<NResult>(Future<NResult> query(Ref ref)) AsyncNotifierProvider<QueryEditable<NResult>, NResult>
Creates an AsyncNotifierProvider for a QueryEditable.
createQueryEditableFamily<NResult, NParam>(Future<NResult> query(Ref ref, NParam param)) → AsyncNotifierProviderFamily<QueryEditableFamily<NResult, NParam>, NResult, NParam>
Creates an AsyncNotifierProviderFamily for a QueryEditableFamily.
createQueryEditableFamilyPersist<NResult, NParam>(Future<NResult> query(Ref ref, NParam param)) → AsyncNotifierProviderFamily<QueryEditableFamily<NResult, NParam>, NResult, NParam>
Creates an AsyncNotifierProviderFamily for a QueryEditableFamily that persists its state.
createQueryEditablePersist<NResult>(Future<NResult> query(Ref ref)) AsyncNotifierProvider<QueryEditable<NResult>, NResult>
Creates an AsyncNotifierProvider for a QueryEditable that persists its state.
createQueryFamily<T, TParam>(Future<T> query(Ref ref, TParam param)) FutureProviderFamily<T, TParam>
Creates a FutureProviderFamily that automatically disposes of its state when listener count reaches zero.
createQueryFamilyPersist<T, TParam>(Future<T> query(Ref ref, TParam param)) FutureProviderFamily<T, TParam>
Creates a FutureProviderFamily that persists its state even when there are no listeners.
createQueryPersist<T>(Future<T> query(Ref ref)) FutureProvider<T>
Creates a FutureProvider that persists its state even when there are no listeners.
createStore<T>(T store(Ref ref)) Provider<T>
Creates a Provider that automatically disposes of its state when listener count reaches zero.
createStoreFamily<T, TParam>(T store(Ref ref, TParam param)) ProviderFamily<T, TParam>
Creates a ProviderFamily that automatically disposes of its state when listener count reaches zero.
createStoreFamilyPersist<T, TParam>(T store(Ref ref, TParam param)) ProviderFamily<T, TParam>
Creates a ProviderFamily that persists its state even when there are no listeners.
createStorePersist<T>(T store(Ref ref)) Provider<T>
Creates a Provider that persists its state even when there are no listeners.

Typedefs

FetchFunction<T, TCursor> = Future<List<T>> Function(TCursor? cursor)
A function that fetches a list of items based on a cursor.
FutureCallback = Future<void> Function()
A callback function that returns a Future.
NextCursorFunction<T, TCursor> = TCursor? Function(List<T>? lastPage, List<List<T>> pages)
A function that determines the next cursor based on the last loaded page and all loaded pages.

Exceptions / Errors

AsyncValueIsLoadingException
AsyncValue.requireValue was called on an AsyncValue with no error nor a value.
ProviderException
An exception thrown when trying to read a provider that is in error state.