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 returnsfalse
.no setterinherited - isSuccess → bool
-
Returns
true
if this instance represents a successful outcome. In this case isFailure returnsfalse
.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
, thetoString
method will be overridden to output this instance'sprops
.no setterinherited
Methods
-
exceptionOrNull(
) → Object? -
Available on Result<
Returns the encapsulated Object error if this instance represents Failure orT> , provided by the PatternMatching extensionnull
if it is Success. -
flatMap<
R> (Result< R> transform(T value)) → Result<R> -
Available on Result<
Transforms this Result<T> to Result<R> by applyingT> , provided by the PatternMatching extensiontransform
if this is a Success, or returns the Failure unchanged if this is a Failure. -
flatMapAsync<
R> (Future< Result< transform(T value)) → Future<R> >Result< R> > -
Available on Result<
Asynchronously transforms this Result<T> to Result<R> by applyingT> , provided by the PatternMatching extensiontransform
if this is a Success, or returns the Failure unchanged if this is a Failure. -
flatten<
R> () → Result< R> -
Available on Result<
Flattens a nested Result of Result to a single Result. Only works whenT> , provided by the PatternMatching extensionT
is of type Result<R>. -
fold<
R> ({required R onSuccess(T value), required R onFailure(Object error, StackTrace? stackTrace)}) → R -
Available on Result<
Returns the result ofT> , provided by the PatternMatching extensiononSuccess
for the encapsulated value if this instance represents Success or the result ofonFailure
function for the encapsulated error if it is Failure. -
getOrDefault<
R> (R defaultValue) → R -
Available on Result<
Returns the encapsulated value if this instance represents Success or theT> , provided by the PatternMatching extensiondefaultValue
if it is Failure. -
getOrElse<
R> (R onFailure(Object error, StackTrace? stackTrace)) → R -
Available on Result<
Returns the encapsulated value if this instance represents Success or the result ofT> , provided by the PatternMatching extensiononFailure
function for the encapsulated error if it is Failure. -
getOrNull(
) → T? -
Available on Result<
Returns the encapsulated value if this instance represents Success orT> , provided by the PatternMatching extensionnull
if it is Failure. -
getOrThrow(
) → T -
Available on Result<
Returns the encapsulated value if this instance represents Success or throws the encapsulated error if it is Failure.T> , provided by the PatternMatching extension -
map<
R> (R transform(T value)) → Result< R> -
Available on Result<
Returns the encapsulated result of the givenT> , provided by the PatternMatching extensiontransform
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<
Asynchronously returns the encapsulated result of the givenT> , provided by the PatternMatching extensiontransform
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<
Returns the encapsulated result of the givenT> , provided by the PatternMatching extensiontransform
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<
Performs the givenT> , provided by the PatternMatching extensionaction
on the encapsulated error if this instance represents Failure. Returns the original Result unchanged. -
onSuccess(
void action(T value)) → Result< T> -
Available on Result<
Performs the givenT> , provided by the PatternMatching extensionaction
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<
Returns the encapsulated result of the givenT> , provided by the PatternMatching extensiontransform
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<
Returns the encapsulated result of the givenT> , provided by the PatternMatching extensiontransform
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<
Returns the encapsulated StackTrace if this instance represents Failure orT> , provided by the PatternMatching extensionnull
if it is Success. -
toString(
) → String - A string representation of this object.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited