Result<T> class sealed

Sealed discriminated union for success / failure without exceptions escaping the network layer. Inspired by Rust's Result<T, E>.

Implementers

Properties

data → T
Unwraps the value; throws StateError if this is a Failure.
no setter
error NetworkException
Unwraps the error; throws StateError if this is a Success.
no setter
hashCode int
The hash code for this object.
no setterinherited
isFailure bool
Returns true when this is a Failure.
no setter
isSuccess bool
Returns true when this is a Success.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

fold<R>({required R onSuccess(T value), required R onFailure(NetworkException error)}) → R
Fold into a single value regardless of variant.
map<R>(R transform(T value)) Result<R>
Transforms a Success value; passes Failure through unchanged.
mapAsync<R>(Future<R> transform(T value)) Future<Result<R>>
Async variant of map.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void action(NetworkException error)) Result<T>
Run a side-effect on failure, then return this unchanged.
onSuccess(void action(T value)) Result<T>
Run a side-effect on success, then return this unchanged.
toString() String
A string representation of this object.
inherited

Operators

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