Success<T> class
The successful outcome of a Result.
Example:
final result = Success(42);
print(result.value); // 42
print(result.isSuccess); // true
Constructors
- Success(T value)
-
Creates a successful result wrapping
value.const
Properties
- errorOrNull → Object?
-
Returns the error on Failure, or
nullon Success.no setterinherited - hashCode → int
-
The hash code for this object.
no setteroverride
- isFailure → bool
-
Whether this result is a Failure.
no setterinherited
- isSuccess → bool
-
Whether this result is a Success.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
The successful value.
final
- valueOrNull → T?
-
Returns the value on Success, or
nullon Failure.no setterinherited
Methods
-
flatMap<
R> (Result< R> mapper(T value)) → Result<R> -
Chains Results —
mapperis only called on Success.inherited -
getOrElse(
T fallback(Object error)) → T -
Returns the value on Success, or calls
fallbackwith the error on Failure.inherited -
map<
R> (R mapper(T value)) → Result< R> -
Transforms the value on Success, passes Failure through unchanged.
inherited
-
maybeWhen<
R> ({R success(T value)?, R failure(Object error)?, required R orElse()}) → R -
Optional pattern match — unhandled cases fall through to
orElse.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toAsyncValue(
) → AsyncValue< T> -
Converts to AsyncValue — Success becomes AsyncData, Failure becomes AsyncError.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
when<
R> ({required R success(T value), required R failure(Object error)}) → R -
Exhaustive pattern match — all cases required.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override