OperationAsyncData<E extends Object?, D extends Object?> class abstract

A sum type for asynchronous data that is obtained as a result of an operation.

Has four variations – initial, loading, success and error. success stores data, while error stores error and initial and loading are empty.

An example of usage would be a result of an HTTP request through its stages.

Implementers
Annotations
  • @immutable
  • @sealed

Constructors

OperationAsyncData.error({required E error})
const
factory
OperationAsyncData.initial()
const
factory
OperationAsyncData.loading()
const
factory
OperationAsyncData.success({required D data})
const
factory

Properties

data → D?
no setter
error → E?
no setter
hasData bool
no setter
hasError bool
no setter
hashCode int
The hash code for this object.
no setterinherited
isError bool
no setter
isInitial bool
no setter
isLoading bool
no setter
isSuccess bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

flatMap<B extends Object?>(OperationAsyncData<E, B> mapper(D data)) OperationAsyncData<E, B>
map<B extends Object?>(B mapper(D data)) OperationAsyncData<E, B>
mapError<A extends Object?>(A mapper(E error)) OperationAsyncData<A, D>
match<R>({required R initial(OperationAsyncDataInitial<Object?, Object?> data), required R loading(OperationAsyncDataLoading<Object?, Object?> data), required R success(OperationAsyncDataSuccess<E, D> data), required R error(OperationAsyncDataError<E, D> data)}) → R
matchOr<R>({R initial(OperationAsyncDataInitial<Object?, Object?> data)?, R loading(OperationAsyncDataLoading<Object?, Object?> data)?, R success(OperationAsyncDataSuccess<E, D> data)?, R error(OperationAsyncDataError<E, D> data)?, required R fallback()}) → R
matchOrNull<R>({R initial(OperationAsyncDataInitial<Object?, Object?> data)?, R loading(OperationAsyncDataLoading<Object?, Object?> data)?, R success(OperationAsyncDataSuccess<E, D> data)?, R error(OperationAsyncDataError<E, D> data)?}) → R?
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
when<R>({required R initial(), required R loading(), required R success(D data), required R error(E error)}) → R
whenOr<R>({R initial()?, R loading()?, R success(D data)?, R error(E error)?, required R fallback()}) → R
whenOrNull<R>({R initial()?, R loading()?, R success(D data)?, R error(E error)?}) → R?

Operators

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

Static Methods

fromOperation<E extends Object?, D extends Object?>({required Future<D> body(), required E onError(Object error, StackTrace stackTrace), bool shouldRethrow = false}) Stream<OperationAsyncData<E, D>>