AsyncValueX<T> extension

An extension that adds methods like when to an AsyncValue.

on

Properties

asData AsyncData<T>?

Available on AsyncValue<T>, provided by the AsyncValueX extension

Upcast AsyncValue into an AsyncData, or return null if the AsyncValue is an AsyncLoading/AsyncError.
no setter
asError AsyncError<T>?

Available on AsyncValue<T>, provided by the AsyncValueX extension

Upcast AsyncValue into an AsyncError, or return null if the AsyncValue is an AsyncLoading/AsyncData.
no setter
hasError bool

Available on AsyncValue<T>, provided by the AsyncValueX extension

Whether error is not null.
no setter
isRefreshing bool

Available on AsyncValue<T>, provided by the AsyncValueX extension

Whether the associated provider was forced to recompute even though none of its dependencies has changed, after at least one value/error was emitted.
no setter
isReloading bool

Available on AsyncValue<T>, provided by the AsyncValueX extension

Whether the associated provider was recomputed because of a dependency change (using Ref.watch), after at least one value/error was emitted.
no setter
requireValue → T

Available on AsyncValue<T>, provided by the AsyncValueX extension

If hasValue is true, returns the value. Otherwise if hasError, rethrows the error. Finally if in loading state, throws a StateError.
no setter
valueOrNull → T?

Available on AsyncValue<T>, provided by the AsyncValueX extension

Return the value or previous value if in loading/error state.
no setter

Methods

mapOrNull<R>({R? data(AsyncData<T> data)?, R? error(AsyncError<T> error)?, R? loading(AsyncLoading<T> loading)?}) → R?

Available on AsyncValue<T>, provided by the AsyncValueX extension

Perform some actions based on the state of the AsyncValue, or return null if the current state wasn't tested.
maybeMap<R>({R data(AsyncData<T> data)?, R error(AsyncError<T> error)?, R loading(AsyncLoading<T> loading)?, required R orElse()}) → R

Available on AsyncValue<T>, provided by the AsyncValueX extension

Perform some actions based on the state of the AsyncValue, or call orElse if the current state was not tested.
maybeWhen<R>({bool skipLoadingOnReload = false, bool skipLoadingOnRefresh = true, bool skipError = false, R data(T data)?, R error(Object error, StackTrace stackTrace)?, R loading()?, required R orElse()}) → R

Available on AsyncValue<T>, provided by the AsyncValueX extension

Switch-case over the state of the AsyncValue while purposefully not handling some cases.
when<R>({bool skipLoadingOnReload = false, bool skipLoadingOnRefresh = true, bool skipError = false, required R data(T data), required R error(Object error, StackTrace stackTrace), required R loading()}) → R

Available on AsyncValue<T>, provided by the AsyncValueX extension

Performs an action based on the state of the AsyncValue.
whenData<R>(R cb(T value)) AsyncValue<R>

Available on AsyncValue<T>, provided by the AsyncValueX extension

Shorthand for when to handle only the data case.
whenOrNull<R>({bool skipLoadingOnReload = false, bool skipLoadingOnRefresh = true, bool skipError = false, R? data(T data)?, R? error(Object error, StackTrace stackTrace)?, R? loading()?}) → R?

Available on AsyncValue<T>, provided by the AsyncValueX extension

Perform actions conditionally based on the state of the AsyncValue.