Success<S extends Object, F extends Object> class
final
Success Result.
return it when the result of a Result is the expected value.
- Implemented types
-
- ResultDart<
S, F>
- ResultDart<
- Available extensions
- Annotations
Constructors
- Success(S _success)
-
Receives the
Sparam as the successful result.const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
exceptionOrNull(
) → F? -
Returns the value of Failure or null.
override
-
filter(
bool test(S success), F orElse(S success)) → ResultDart< S, F> -
Returns this Result if it is a Failure or if the
testpredicate returnstruefor the encapsulated Success value. Otherwise, returns a Failure created byorElse.override -
flatMap<
W extends Object> (ResultDart< W, F> fn(S success)) → ResultDart<W, F> -
Returns a new
Result, mapping anySuccessvalue using the given transformation and unwrapping the producedResult.override -
flatMapError<
W extends Object> (ResultDart< S, W> fn(F failure)) → ResultDart<S, W> -
Returns a new
Result, mapping anyErrorvalue using the given transformation and unwrapping the producedResult.override -
flatten(
) → ResultDart< S, F> -
Available on ResultDart<
Flattens a nested ResultDart by removing one level of nesting.ResultDart< , provided by the FlattenResultExtension extensionS, F> , F> -
fold<
W> (W onSuccess(S success), W onFailure(F error)) → W -
Returns the result of onSuccess for the encapsulated value
if this instance represents
Successor the result of onError function for the encapsulated value if it isFailure.override -
getOrDefault(
S defaultValue) → S -
Returns the encapsulated value if this instance represents
Successor thedefaultValueif it isFailure.override -
getOrElse(
S onFailure(F failure)) → S -
Returns the encapsulated value if this instance represents
Successor the result ofonFailurefunction for the encapsulated aFailurevalue.override -
getOrNull(
) → S -
Returns the value of Success or null.
override
-
getOrThrow(
) → S -
Returns the success value as a throwing expression.
override
-
isError(
) → bool -
Returns true if the current result is an Failure.
override
-
isSuccess(
) → bool -
Returns true if the current result is a Success.
override
-
map<
W extends Object> (W fn(S success)) → ResultDart< W, F> -
Returns a new
Result, mapping anySuccessvalue using the given transformation.override -
mapError<
W extends Object> (W fn(F error)) → ResultDart< S, W> -
Returns a new
Result, mapping anyErrorvalue using the given transformation.override -
mapFold<
G extends Object, W extends Object> (G onSuccess(S success), W onFailure(F failure)) → ResultDart< G, W> -
Returns a new
Result, mapping anySuccessvalue using the given transformation and unwrapping the producedResult. Returns a newResult, mapping anyErrorvalue using the given transformation and unwrapping the producedResult.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFailure(
void onFailure(F failure)) → ResultDart< S, F> -
Performs the given action on the encapsulated Throwable
exception if this instance represents failure.
Returns the original Result unchanged.
override
-
onSuccess(
void onSuccess(S success)) → ResultDart< S, F> -
Performs the given action on the encapsulated value if this
instance represents success. Returns the original Result unchanged.
override
-
pure<
W extends Object> (W success) → ResultDart< W, F> -
Change the Success value.
override
-
pureError<
W extends Object> (W error) → ResultDart< S, W> -
Change the Failure value.
override
-
pureFold<
G extends Object, W extends Object> (G success, W failure) → ResultDart< G, W> -
Returns a new
Result, mapping anySuccessvalue using the given transformation and unwrapping the producedResult. Returns a newResult, mapping anyErrorvalue using the given transformation and unwrapping the producedResult.override -
recover<
R extends Object> (ResultDart< S, R> onFailure(F failure)) → ResultDart<S, W> -
Returns the encapsulated
Resultof the given transform function applied to the encapsulated aFailureor the original encapsulated value if it is success.override -
recoverWhen(
bool test(F failure), ResultDart< S, F> onFailure(F failure)) → ResultDart<S, F> -
Returns the encapsulated Result of the given
onFailurefunction applied to the encapsulated Failure value only iftestreturnstrue. Otherwise, returns the original Failure unchanged. If this is a Success, returns it unchanged.override -
swap(
) → ResultDart< F, S> -
Swap the values contained inside the Success and Failure
of this Result.
override
-
tap(
void fn(ResultDart< S, F> result)) → ResultDart<S, F> -
Performs the given action on this Result regardless of whether it
is a Success or Failure. Returns the original Result unchanged.
override
-
toAsyncResult(
) → AsyncResultDart< S, F> -
Return a AsyncResult.
override
-
toEffect(
) → Effect< A, E> -
Available on ResultDart<
A, E> , provided by the ResultDartEffectInterop extension -
toString(
) → String -
A string representation of this object.
override
-
zip<
S2 extends Object> (ResultDart< S2, F> other) → ResultDart<(S, S2), F> -
Combines this Result with
otherinto a single Result containing aRecordof both success values. If either is a Failure, returns the first Failure encountered.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override