result_notifier library

Pragmatic state management for Flutter, based on familiar and platform-native concepts

Classes

AsyncEffectNotifier<S, R>
Result notifier that executes an "effect" asynchronously whenever a source ResultNotifier changes value.
CombineLatestNotifier<S, R>
Combines the data of a number of source ResultNotifiers into a single data value, held by this notifier.
Data<T>
Represents a result containing actual data.
Error<T>
Represents an error, along with the previous data, if any.
FutureNotifier<T>
ResultNotifier subclass that supports fetching data asynchronously, on demand.
Initial<T>
Initial loading/empty state. Inherits from Loading and is handled as such in most cases.
Loading<T>
Represents a loading/reloading state, along with the previous data, if any.
ResourceProvider<T>
Stateful convenience Widget that manages the lifecycle (creation and disposal) of a resource and makes it available when building this Widget, as well as to all descendant Widgets (see of).
ResourceProviderState<T>
The state of a ResourceProvider.
Result<T>
Result is the base class of an enumerable set of subtypes that represent the different states involved in fetching data for a ResultNotifier.
ResultListenable<T>
Abstract class/mixin for ValueListenable subclasses that holds a Result.
ResultNotifier<T>
ValueListenable implementation that holds a single Result value, supporting data, loading and error states.
ResultStore<K, T>
A ChangeNotifier that creates and caches ResultNotifiers for a given key, and optionally disposes them when they are no longer used.
StatefulWatcherWidget
Stateful widget that adds observability of Listenables, through the WatcherContext (a BuildContext subclass) provided to the build method of the associated WatcherState.
StreamEffectNotifier<S, R>
Result notifier that executes an "effect" that returns a Stream, whenever a source ResultNotifier changes value.
StreamNotifier<T>
ResultNotifier subclass that supports fetching streaming data.
SyncEffectNotifier<S, R>
Result notifier that executes an "effect" whenever a source ResultNotifier changes value.
Watcher
Stateless widget that supports watching Listenables within a provided builder function.
WatcherContext
A BuildContext that implements WatcherRef.
WatcherRef
A reference object that enables support for watching Listenables within a Widget.
WatcherState<T extends StatefulWatcherMixin>
The State of a StatefulWatcherWidget, that adds observability of Listenables, through the WatcherContext (a BuildContext subclass) provided to the build method.
WatcherWidget
Stateless widget that adds observability of Listenables, through the WatcherContext (a BuildContext subclass) provided to the build method.

Mixins

EffectNotifier<S, R>
Result notifier that executes an "effect" whenever a source ResultNotifier changes value.
StatefulWatcherMixin
Mixin to add observability of Listenables to a StatefulWidget.
StreamableResultNotifierMixin<T>
Mixin to support listening via a Stream.
WatcherMixin
Mixin to add observability of Listenables to a StatelessWidget.

Extensions

ListenableWatcher on Listenable
Listenable extension that adds observability (i.e. watch method).
ResourceProviderContext on BuildContext
Convenience extensions on BuildContext that adds lookup of a resource provided by a ResourceProvider.
ResultIterable on Iterable<Result<S>>
Extension on Iterables containing Results.
ResultIterableEffects on Iterable<Result<S>>
Effect extension on Iterables containing Results.
ResultListenableIterableEffects on Iterable<ResultListenable<S>>
Effect extension on Iterables containing ResultNotifiers (or ResultListenables).
ResultListenableQuadrupleMethods on ResultListenableQuadruple<A, B, C, D>
Record extension providing convenience extension methods.
ResultListenableQuintupleMethods on ResultListenableQuintuple<A, B, C, D, E>
Record extension providing convenience extension methods.
ResultListenableTripleMethods on ResultListenableTriple<A, B, C>
Record extension providing convenience extension methods.
ResultListenableTupleMethods on ResultListenableTuple<A, B>
Record extension providing convenience extension methods.
ResultNotifierIterable on Iterable<ResultListenable<S>>
Extension on Iterables containing ResultNotifiers.
ResultNotifierWatcher on ResultNotifier<T>
ResultNotifier extension that adds observability (i.e. watch method).
ResultQuadrupleMethods on ResultQuadruple<A, B, C, D>
Record extension providing convenience extension methods.
ResultQuintupleMethods on ResultQuintuple<A, B, C, D, E>
Record extension providing convenience extension methods.
ResultTripleMethods on ResultTriple<A, B, C>
Record extension providing convenience extension methods.
ResultTupleMethods on ResultTuple<A, B>
Record extension providing convenience extension methods.
ValueListenableToResultListenable on ValueListenable<T>
Extension for converting a ValueListenable to a ResultListenable.
ValueListenableWatcher on ValueListenable<T>
ValueListenable extension that adds observability (i.e. watch method).

Typedefs

AsyncEffect<S, R> = Future<R> Function(ResultNotifier<R> notifier, S input)
Signature for functions used by AsyncEffectNotifier to execute an action that returns data Future, using the data of a source ResultNotifier as input.
AsyncResultEffect<S, R> = Future<Result<R>> Function(ResultNotifier<R> notifier, S input)
Signature for functions used by AsyncEffectNotifier to execute an action that returns a Result Future, using the data of a source ResultNotifier as input.
Combine<S, R> = R Function(List<S> data)
Signature for functions used by CombineLatestNotifier to combine data from a number of source ResultNotifiers into a single value.
CombineResult<S, R> = Result<R> Function(Iterable<Result<S>> data)
Signature for functions used by CombineLatestNotifier to combine Results from a number of source ResultNotifiers into a single value.
CreateResource<T> = T Function(BuildContext context)
Signature for functions that creates a resource.
CreateResultNotifier<K, T> = ResultNotifier<T> Function(K key, ResultStore<K, T> store)
DisposeResource<T> = void Function(BuildContext context, T resource)
Signature for functions that disposes a resource.
Effect<S, R> = R Function(SyncEffectNotifier<S, R> notifier, S input)
Signature for functions used by SyncEffectNotifier to execute an action that returns data, using the data of a source ResultNotifier as input.
FetchAsync<T> = FutureOr<T> Function(ResultNotifier<T> notifier)
Signature for functions that fetches data asynchronously for an FutureNotifier.
FetchResultAsync<T> = FutureOr<Result<T>> Function(ResultNotifier<T> notifier)
Signature for functions that fetches data asynchronously for an FutureNotifier, and returns a Result.
FetchResultStream<T> = Stream<Result<T>> Function(StreamNotifier<T> notifier)
Signature for functions that fetches streaming Results for a StreamNotifier.
FetchStream<T> = Stream<T> Function(StreamNotifier<T> notifier)
Signature for functions that fetches streaming data for a StreamNotifier.
ResourceWidgetBuilder<T> = Widget Function(WatcherContext context, T resource)
Signature for functions that builds a Widget using a resource.
ResultEffect<S, R> = Result<R> Function(SyncEffectNotifier<S, R> notifier, S input)
Signature for functions used by SyncEffectNotifier to execute an action that returns a Result, using the data of a source ResultNotifier as input.
ResultListenableQuadruple<A, B, C, D> = (ResultListenable<A>, ResultListenable<B>, ResultListenable<C>, ResultListenable<D>)
Convenience record to enable easy access to typed extensions methods on ResultNotifier (or ResultListenable) (via ResultListenableQuadrupleMethods).
ResultListenableQuintuple<A, B, C, D, E> = (ResultListenable<A>, ResultListenable<B>, ResultListenable<C>, ResultListenable<D>, ResultListenable<E>)
Convenience record to enable easy access to typed extensions methods on ResultNotifier (or ResultListenable) (via ResultListenableQuintupleMethods).
ResultListenableTriple<A, B, C> = (ResultListenable<A>, ResultListenable<B>, ResultListenable<C>)
Convenience record to enable easy access to typed extensions methods on ResultNotifier (or ResultListenable) (via ResultListenableTripleMethods).
ResultListenableTuple<A, B> = (ResultListenable<A>, ResultListenable<B>)
Convenience record to enable easy access to typed extensions methods on ResultNotifier (or ResultListenable) (via ResultListenableTupleMethods).
ResultNotifierCallback<T> = void Function(ResultNotifier<T> notifier)
Signature for callback functions used by ResultNotifier.
ResultNotifierOnDispose<K, T> = void Function(K key, ResultNotifier<T> strore)
ResultQuadruple<A, B, C, D> = (Result<A>, Result<B>, Result<C>, Result<D>)
Convenience record to enable easy access to typed extensions methods on Result (via ResultQuadrupleMethods).
ResultQuintuple<A, B, C, D, E> = (Result<A>, Result<B>, Result<C>, Result<D>, Result<E>)
Convenience record to enable easy access to typed extensions methods on Result (via ResultQuintupleMethods).
ResultStreamEffect<S, R> = Stream<Result<R>> Function(ResultNotifier<R> notifier, S input)
Signature for functions used by StreamEffectNotifier to execute an action that returns a Result Stream, using the data of a source ResultNotifier as input.
ResultTriple<A, B, C> = (Result<A>, Result<B>, Result<C>)
Convenience record to enable easy access to typed extensions methods on Result (via ResultTripleMethods).
ResultTuple<A, B> = (Result<A>, Result<B>)
Convenience record to enable easy access to typed extensions methods on Result (via ResultTupleMethods).
StreamEffect<S, R> = Stream<R> Function(ResultNotifier<R> notifier, S input)
Signature for functions used by StreamEffectNotifier to execute an action that returns data Stream, using the data of a source ResultNotifier as input.

Exceptions / Errors

CancelledException
Exception thrown when a data fetch operation is cancelled.
DisposedException
Exception thrown when a ResultNotifier is disposed.
NoDataException
Exception thrown when data is not available (or failed to fetch) and no other error is available.
ResultNotifierException
Base class for all exceptions used by ResultNotifier.