CombineLatestNotifier<S, R> class

Combines the data of a number of source ResultNotifiers into a single data value, held by this notifier.

The resulting data is produced by the specified combineData function, which is called whenever one of the source notifiers updates its data.

See also:

Inheritance
Mixed in types
Available Extensions

Constructors

CombineLatestNotifier(Iterable<ResultListenable<S>> notifiers, {required Combine<S, R> combineData, R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool immediate = false, bool ignoreLoading = false})
Constructs a CombineLatestNotifier that combines the data from the provided source notifiers, using the specified combineData function.
CombineLatestNotifier.result(Iterable<ResultListenable<S>> notifiers, {required CombineResult<S, R> combineResult, R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool immediate = false, bool ignoreLoading = false})
Constructs a CombineLatestNotifier that combines the results from the provided source notifiers, using the specified combineResult function.

Properties

data ↔ R
Attempts to get the Result.data of the current Result value.
getter/setter pairinherited
dataOrNull → R?
Get the Result.data of the current Result value, or null if no data is available (i.e. hasData is false).
no setterinherited
error Object?
no setterinherited
expiration Duration?
Cache expiration time. If null, the cache will never expire.
finalinherited
future Future<R>
If data or error is available, it will be returned directly (as Future.value / Future.error), otherwise a Completer will be used to await data or error.
getter/setter pairinherited
hasData bool
Checks if the result contains data, regardless of the result type. Note that this is different from isData.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
ignoreLoading bool
If true, any Loading state of the input notifiers will be ignored, and the previous result will be kept.
final
isActive bool
Checks if this notifier is still active, i.e. not disposed.
no setterinherited
isAlwaysFresh bool
Returns true if no expiration has been set, meaning the cache will never expire.
no setterinherited
isCancelled bool
Checks if the current state is Error and the error is a CancelledException.
no setterinherited
isData bool
Checks if the result is Data. Note that this is different from if this notifier currently contains data (i.e. hasData).
no setterinherited
isError bool
Checks if the current state is Error.
no setterinherited
isFresh bool
Checks if the current data is fresh, not stale, i.e. time since last update is less than expiration (if set).
no setterinherited
isInitial bool
Checks if the the result is the Initial loading state.
no setterinherited
isLoading bool
Checks if the the result is Loading. Note that the initial state (Initial) is also interpreted as a loading state.
no setterinherited
isLoadingData bool
Checks if the data is currently being loaded, i.e. the current state is Loading but not Initial.
no setterinherited
isReloading bool
Checks if data is currently being reloaded, i.e. the current state is Loading and hasData.
no setterinherited
isStale bool
Returns true if the current data isn't fresh or if the current result isn't Data.
no setterinherited
lastUpdate DateTime
The last time the result was updated.
no setterinherited
onErrorReturn → (R Function(Object? error)?)
Callback invoked when an error occurs, to produce fallback data.
finalinherited
onFetch ResultNotifierCallback<R>?
Callback invoked when data needs to be fetched.
finalinherited
onReset ResultNotifierCallback<R>?
Callback invoked when this notifier is reset, cancelled or disposed.
finalinherited
result Result<R>
Just an alias for value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
no setterinherited
value Result<R>
The current Result stored in this notifier.
getter/setter pairinherited
willAutoReset bool
If true, this notifier will automatically reset itself when all listeners are removed.
finalinherited
willRefreshOnError bool
If true, the refresh method will fetch new data when the current state is Error.
finalinherited

Methods

addListener(VoidCallback listener) → void
Adds a listener to this notifier and triggers an asynchronous refreshes the data, if necessary.
inherited
alwaysData(R defaultData) ResultNotifier<R>
Creates a new ResultNotifier that only gets updated when the data of this notifier changes, i.e. ignoring Loading and Error states.
inherited
asyncEffect<R>(AsyncEffect<R, R> effect, {R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) EffectNotifier<R, R>
Creates a new asynchronous EffectNotifier that executes the provided asynchronous effect the data of this notifier changes.
inherited
builder(Widget builder(BuildContext context, Result<R> result, Widget? child), {Widget? child}) ValueListenableBuilder<Result<R>>
Convenience method for simplifying the creation of a ValueListenableBuilder with ResultNotifier.
inherited
cancel({bool always = false}) → void
Cancels the current data loading operation, if any.
inherited
combineLatest<R>(ResultListenable<R> other, {required R combineData(List<R> data)}) CombineLatestNotifier<R, R>
Creates a new CombineLatestNotifier that that combines the value of this notifier with another one.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
effect<R>(Effect<R, R> effect, {R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) EffectNotifier<R, R>
Creates a new synchronous EffectNotifier that executes the provided effect the data of this notifier changes.
inherited
fetchData() → void
Called to fetch new data.
inherited
invalidate() Result<R>
Marks the current Data (if any) as stale, i.e. it will be re-fetched on next access.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onData(void listener(R data)) VoidCallback
Registers a listener (addListener) that will only be invoked for Data results.
inherited
onError(void listener(Object? error, StackTrace? stackTrace, R? data)) VoidCallback
Registers a listener (addListener) that will only be invoked for Error results.
inherited
onLoading(void listener(R? data)) VoidCallback
Registers a listener (addListener) that will only be invoked for Loading results.
inherited
onResult(void listener(Result<R> result)) VoidCallback
Registers a listener (addListener) that will be invoked with the current Result (value).
inherited
refresh({bool force = false, bool alwaysTouch = false}) → void
Refreshes this notifier with fresh Data if it is stale or forced.
inherited
refreshAwait({bool force = false, bool alwaysTouch = false}) Future<R>
Refreshes this notifier with fresh Data if it is stale or forced, and awaits data or error.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
reset([R? initialData]) → void
Resets the result to Initial, or to stale Data if initialData is specified.
inherited
setDataAsync(FutureOr<R> fetchData()) Future<R>
Sets the data of this notifier asynchronously using the data returned by the provided function, which in turn is returned by this method (in form of a Future).
inherited
setResultAsync(FutureOr<Result<R>> fetchResult()) Future<Result<R>>
Sets the value (result) of this notifier asynchronously using the result returned by the provided function.
inherited
streamEffect<R>(StreamEffect<R, R> effect, {R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) EffectNotifier<R, R>
Creates a new asynchronous EffectNotifier that executes the provided strean effect the data of this notifier changes.
inherited
toCancelled({R? data, DateTime? lastUpdate}) Result<R>
Attempts to convert the result to cancellation Error.
inherited
toData({R? data, R orElse()?, DateTime? lastUpdate}) Result<R>
Attempts to convert the result to Data.
inherited
toError({Object? error, StackTrace? stackTrace, R? data, DateTime? lastUpdate}) Result<R>
Attempts to convert the result to Error.
inherited
toInitial({R? data, DateTime? lastUpdate}) Result<R>
Attempts to convert the result to the Initial loading state.
inherited
toLoading({R? data, DateTime? lastUpdate}) Result<R>
Attempts to convert the result to Loading.
inherited
toString() String
A string representation of this object.
inherited
touch() Result<R>
Attempts to convert the result to fresh Data (i.e. set the lastUpdate to DateTime.now()), preventing cache expiration.
inherited
updateDataAsync(FutureOr<R> fetchData()) Future<void>
Updates the data of this notifier asynchronously using the data returned by the provided function, and then returns a Future that can optionally be used to await the completion of the update.
inherited

Operators

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

Static Methods

combine2<A, B, R>(ResultListenable<A> notifierA, ResultListenable<B> notifierB, {required R combineData(A a, B b), R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) CombineLatestNotifier<dynamic, R>
Constructs a CombineLatestNotifier that combines the data from the provided notifiers using the specified combineData function.
combine3<A, B, C, R>(ResultListenable<A> notifierA, ResultListenable<B> notifierB, ResultListenable<C> notifierC, {required R combineData(A a, B b, C c), R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) CombineLatestNotifier<dynamic, R>
Constructs a CombineLatestNotifier that combines the data from the provided notifiers using the specified combineData function.
combine4<A, B, C, D, R>(ResultListenable<A> notifierA, ResultListenable<B> notifierB, ResultListenable<C> notifierC, ResultListenable<D> notifierD, {required R combineData(A a, B b, C c, D d), R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) CombineLatestNotifier<dynamic, R>
Constructs a CombineLatestNotifier that combines the data from the provided notifiers using the specified combineData function.
combine5<A, B, C, D, E, R>(ResultListenable<A> notifierA, ResultListenable<B> notifierB, ResultListenable<C> notifierC, ResultListenable<D> notifierD, ResultListenable<E> notifierE, {required R combineData(A a, B b, C c, D d, E e), R? data, Result<R>? result, Duration? expiration, ResultNotifierCallback<R>? onReset, R onErrorReturn(Object? error)?, bool autoReset = false, bool refreshOnError = false, bool ignoreLoading = false}) CombineLatestNotifier<dynamic, R>
Constructs a CombineLatestNotifier that combines the data from the specified notifiers using the specified combineData function.