Success<T, E extends Object> class
final
Represents a successful result
Constructors
- Success(T value)
-
const
Properties
- failureOrNull → E?
-
Returns the error if this is a failure, null otherwise
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isFailure → bool
-
Returns true if this result represents a failure
no setterinherited
- isSuccess → bool
-
Returns true if this result represents a success
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- successOrNull → T?
-
Returns the success value if this is a success, null otherwise
no setterinherited
- value → T
-
The success value
final
Methods
-
flatMap<
U> (Result< U, E> mapper(T)) → Result<U, E> -
Flat maps the success value using the given function, preserving failures
inherited
-
fold<
U> (U onSuccess(T), U onFailure(E)) → U -
Folds this result into a single value using the appropriate function
inherited
-
get(
) → T -
Returns the success value if this is a success, or throws the error if this is a failure
inherited
-
getOrElse(
T defaultValue) → T -
Returns the success value if this is a success, or the given default value if this is a failure
inherited
-
map<
U> (U mapper(T)) → Result< U, E> -
Maps the success value using the given function, preserving failures
inherited
-
mapError<
F extends Object> (F mapper(E)) → Result< T, F> -
Maps the error using the given function, preserving successes
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFailure(
void action(E)) → Result< T, E> -
Executes the given function with the error if this is a failure
inherited
-
onSuccess(
void action(T)) → Result< T, E> -
Executes the given function with the success value if this is a success
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override