Result<T> class abstract

A generic class for handling results that can be either success or failure

Implementers
Available extensions

Constructors

Result()
Creates a Result instance
const

Properties

failure Failure?
Returns the failure if failed, null otherwise
no setter
hashCode int
The hash code for this object.
no setterinherited
isFailure bool
Returns true if the result is a failure
no setter
isSuccess bool
Returns true if the result is successful
no setter
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
value → T?
Returns the success value if successful, null otherwise
no setter

Methods

map<R>(R transform(T)) Result<R>
Transforms the success value using the provided function
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void action(Failure)) → void
Executes a function if the result is a failure
onSuccess(void action(T)) → void
Executes a function if the result is successful
toString() String
A string representation of this object.
inherited
unwrap() → T

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

Returns the value if successful, throws the failure message otherwise
unwrapOr(T defaultValue) → T

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

Returns the value if successful, the provided default value otherwise
unwrapOrElse(T defaultValue(Failure)) → T

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

Returns the value if successful, the result of the provided function otherwise

Operators

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