ApiResult<T> class
abstract
Functional result type representing either a success value T or an ApiError.
- Implementers
Constructors
- ApiResult()
-
const
- ApiResult.failure(ApiError error)
-
Creates a failed ApiResult.
factory
- ApiResult.success(T value)
-
Creates a successful ApiResult.
factory
Properties
- data → T?
-
Data payload if successful,
nullotherwise.no setter - error → ApiError?
-
Error details if failed,
nullotherwise.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isFailure → bool
-
trueif the request failed.no setter - isSuccess → bool
-
trueif the request succeeded.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
map<
R> (R mapper(T data)) → ApiResult< R> -
Maps successful result data into type
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 success(T data), required R failure(ApiError error)}) → R - Pattern match handler for success and failure outcomes.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited