AsyncValueX<T> extension Null safety

An extension that adds methods like when to an AsyncValue.

on

Properties

asData AsyncData<T>?
Upcast AsyncValue into an AsyncData, or return null if the AsyncValue is in loading/error state.
read-only
data AsyncData<T>?
Upcast AsyncValue into an AsyncData, or return null if the AsyncValue is in loading/error state.
@Deprecated('use `asData` instead'), read-only
value → T?
Attempts to synchronously. [...]
read-only

Methods

map<R>({required R data(AsyncData<T> data), required R error(AsyncError<T> error), required R loading(AsyncLoading<T> loading)}) → R
Perform some action based on the current state of the AsyncValue. [...]
mapOrNull<R>({R data(AsyncData<T> data)?, R error(AsyncError<T> error)?, R loading(AsyncLoading<T> loading)?}) → R?
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
Perform some actions based on the state of the AsyncValue, or call orElse if the current state was not tested.
maybeWhen<R>({R data(T data)?, R error(Object error, StackTrace? stackTrace)?, R loading()?, required R orElse()}) → R
Switch-case over the state of the AsyncValue while purposefully not handling some cases. [...]
when<R>({required R data(T data), required R error(Object error, StackTrace? stackTrace), required R loading()}) → R
Performs an action based on the state of the AsyncValue. [...]
whenData<R>(R cb(T value)) AsyncValue<R>
Shorthand for when to handle only the data case. [...]
whenOrNull<R>({R data(T data)?, R error(Object error, StackTrace? stackTrace)?, R loading()?}) → R?
Perform actions conditionally based on the state of the AsyncValue. [...]