Success<T> class final

Inheritance

Constructors

Success(T _value)
const

Properties

error ErrorMessage?
An error message in case the result represents a failure.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
isSuccess bool
A getter that returns true if the operation was successful (i.e., no error).
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
A getter that returns the value if the operation was successful, or throws a ResultException if it wasn't.
no setteroverride
valueOrNull → T
A getter that returns the value if the operation was successful, or null if it wasn't.
no setteroverride

Methods

flatMap<R>(R onSuccess(T value), {ExceptionHandler? exceptionHandler, String? errorGroup}) Result<R>
Maps a Result<T> to Result<R> using the provided function. If the original result is a failure, the same error is retained.
override
flatMapAsync<R>(Future<R> onSuccess(T value), {ExceptionHandler? exceptionHandler, String? errorGroup}) FutureOr<Result<R>>
Similar to flatMap, but for asynchronous operations. Maps a Result<T> to FutureOr<Result<R>>.
override
fold<R>(R onSuccess(T value), {required R onFailure(ErrorMessage errorMessage)}) → R
Allows handling the success and failure cases of a Result separately and returns a value of type R.
override
foldNotNull<R>(R onSuccess(T value), {required R onFailure(ErrorMessage errorMessage)}) → R?
Similar to fold, but ensures that the value is not null before calling onSuccess.
override
map({required void onSuccess(T value), required void onFailure(ErrorMessage errorMessage)}) → void
Calls the appropriate callback based on the result being a success or a failure.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void callback(ErrorMessage errorMessage)) → void
Calls the provided callback if the result is a failure.
override
onSuccess(void callback(T value)) → void
Calls the provided callback if the result is a success.
override
recover(T onRecover(ErrorMessage errorMessage)) Success<T>
Recovers from a failure by providing a new value.
override
toString() String
A string representation of this object.
inherited

Operators

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