Result<S, E extends AppException> class
sealed
A type that represents either a success value of type S
or a failure value of type E
.
This implementation is based on the Either monad pattern, commonly used for error handling in functional programming. It forces explicit handling of both success and failure cases, making error handling more predictable and type-safe.
Type parameters:
S
: The type of the success valueE
: The type of the error value, must extend AppException
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFailure → bool
-
Whether this instance represents a failed result
no setter
- isSuccess → bool
-
Whether this instance represents a successful result
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valueOrNull → S?
-
Returns the success value if present, null otherwise
no setter
Methods
-
asyncFold<
T> ({required AsyncSuccessCallback< S, T> onSuccess, required AsyncFailureCallback<E, T> onFailure}) → Future<T> - Asynchronous version of fold that handles Future operations in the success case.
-
fold<
T> ({required SyncSuccessCallback< S, T> onSuccess, required SyncFailureCallback<E, T> onFailure}) → T -
Transforms this result into a value of type
T
by applying the appropriate callback based on whether this is a success or failure. -
map<
T> (T transform(S value)) → Result< T, E> - Transforms the success value of this result while preserving the Result wrapper.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited