Success<T> class

Represents successful result.

Inheritance
Available extensions

Properties

data → T
The T data associated with the result.
final
hashCode int
The hash code for this object.
no setterinherited
isFailure bool
Returns true if this instance represents a failed outcome. In this case isSuccess returns false.
no setterinherited
isSuccess bool
Returns true if this instance represents a successful outcome. In this case isFailure returns false.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

exceptionOrNull() Object?

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated Object error if this instance represents Failure or null if it is Success.
flatMap<R>(Result<R> transform(T value)) Result<R>

Available on Result<T>, provided by the PatternMatching extension

Transforms this Result<T> to Result<R> by applying transform if this is a Success, or returns the Failure unchanged if this is a Failure.
flatMapAsync<R>(Future<Result<R>> transform(T value)) Future<Result<R>>

Available on Result<T>, provided by the PatternMatching extension

Asynchronously transforms this Result<T> to Result<R> by applying transform if this is a Success, or returns the Failure unchanged if this is a Failure.
flatten<R>() Result<R>

Available on Result<T>, provided by the PatternMatching extension

Flattens a nested Result of Result to a single Result. Only works when T is of type Result<R>.
fold<R>({required R onSuccess(T value), required R onFailure(Object error, StackTrace? stackTrace)}) → R

Available on Result<T>, provided by the PatternMatching extension

Returns the result of onSuccess for the encapsulated value if this instance represents Success or the result of onFailure function for the encapsulated error if it is Failure.
getOrDefault<R>(R defaultValue) → R

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated value if this instance represents Success or the defaultValue if it is Failure.
getOrElse<R>(R onFailure(Object error, StackTrace? stackTrace)) → R

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated value if this instance represents Success or the result of onFailure function for the encapsulated error if it is Failure.
getOrNull() → T?

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated value if this instance represents Success or null if it is Failure.
getOrThrow() → T

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated value if this instance represents Success or throws the encapsulated error if it is Failure.
map<R>(R transform(T value)) Result<R>

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents Success or the original encapsulated error if it is Failure.
mapAsync<R>(Future<R> transform(T value)) Future<Result<R>>

Available on Result<T>, provided by the PatternMatching extension

Asynchronously returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents Success or the original encapsulated error if it is Failure.
mapCatching<R>(R transform(T value)) Result<R>

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents Success or the original encapsulated error if it is Failure.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void action(Object error, StackTrace? stackTrace)) Result<T>

Available on Result<T>, provided by the PatternMatching extension

Performs the given action on the encapsulated error if this instance represents Failure. Returns the original Result unchanged.
onSuccess(void action(T value)) Result<T>

Available on Result<T>, provided by the PatternMatching extension

Performs the given action on the encapsulated value if this instance represents Success. Returns the original Result unchanged.
recover<R>(R transform(Object error, StackTrace? stackTrace)) Result<R>

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated result of the given transform function applied to the encapsulated error if this instance represents Failure or the original encapsulated value if it is Success.
recoverCatching<R>(R transform(Object error, StackTrace? stackTrace)) Result<R>

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated result of the given transform function applied to the encapsulated error if this instance represents Failure or the original encapsulated value if it is Success.
stackTraceOrNull() StackTrace?

Available on Result<T>, provided by the PatternMatching extension

Returns the encapsulated StackTrace if this instance represents Failure or null if it is Success.
toString() String
A string representation of this object.

Operators

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