Success<S, E> class
Success Result.
return it when the result of a Result is the expected value.
Constructors
- Success(S _success)
-
Receives the
S
param 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
-
flatMap<
W> (Result< W, E> fn(S success)) → Result<W, E> -
Used to chain multiple functions that return a Result.
You can extract the value of every Success in the chain without
handling all possible missing cases.
If any of the functions in the chain returns Error,
the result is Error.
override
-
isError(
) → bool -
Returns true if the current result is an Error.
override
-
isSuccess(
) → bool -
Returns true if the current result is a Success.
override
-
map<
W> (W fn(S success)) → Result< W, E> -
If the Result is Success, then change its value from type
S
to typeW
using functionfn
.inherited -
mapError<
W> (W fn(E error)) → Result< S, W> -
If the Result is Error, then change its value from type
S
to typeW
using functionfn
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError<
R> (R whenError(E error)) → R? -
Execute
whenError
if the Result is an error.override -
onSuccess<
R> (R whenSuccess(S success)) → R -
Execute
whenSuccess
if the Result is a success.override -
pure<
W> (W success) → Result< W, E> -
Change a Success value.
inherited
-
toAsyncResult(
) → AsyncResult< S, E> -
Return a AsyncResult.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
tryGetError(
) → E? -
Returns the value of
E
if any.override -
tryGetSuccess(
) → S -
Returns the value of
S
if any.override -
when<
W> (W whenSuccess(S success), W whenError(E error)) → W -
Return the result in one of these functions.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override