map<R> method

  1. @override
R map<R>({
  1. required R data(
    1. AsyncData<T> data
    ),
  2. required R error(
    1. AsyncError<T> error
    ),
  3. required R loading(
    1. AsyncLoading<T> loading
    ),
})
override

Perform some action based on the current state of the AsyncValue.

This allows reading the content of an AsyncValue in a type-safe way, without potentially ignoring to handle a case.

Implementation

@override
R map<R>({
  required R Function(AsyncData<T> data) data,
  required R Function(AsyncError<T> error) error,
  required R Function(AsyncLoading<T> loading) loading,
}) {
  return data(this);
}