mapOrNull<R> method

R? mapOrNull<R>(
  1. {R data(
    1. AsyncData<T> data
    )?,
  2. R error(
    1. AsyncError<T> error
    )?,
  3. R loading(
    1. AsyncLoading<T> loading
    )?}
)

Perform some actions based on the state of the AsyncValue, or return null if the current state wasn't tested.

Implementation

R? mapOrNull<R>({
  R Function(AsyncData<T> data)? data,
  R Function(AsyncError<T> error)? error,
  R Function(AsyncLoading<T> loading)? loading,
}) {
  return _map(
    data: (d) => data?.call(d),
    error: (d) => error?.call(d),
    loading: (d) => loading?.call(d),
  );
}