Result<T extends Object> class sealed

A Monad that represents the result of an operation: every Result is either Ok and contains a success value, or Err and contains an error value.

Inheritance
Available extensions

Properties

hashCode int
The hash code for this object.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
value Object
finalinherited

Methods

asResult() Result<T>
Returns this as a base Result type.
asVoid() Result<void>
Transforms the contained value to void.
override
end() → void
Suppresses the linter error must_use_monad.
override
err() Option<Err<T>>
Safely gets the Err instance. Returns a Some on Err, or a None on Ok.
errOr(Result<T> other) Result<T>
Returns this if it's Err, otherwise returns the other Result.
flatMap<R extends Object>(Result<R> noFuturesAllowed(T value)) Result<R>
Maps a Result<T> to Result<R> by applying a function that returns another Result.
flatten() Result<T>

Available on Result<Result<Result<Result<Result<T>>>>>, provided by the FlattenResult5 extension

flatten() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<Result<Result<T>>>>>>>>>, provided by the FlattenResult9 extension

flatten() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<Result<T>>>>>>>>, provided by the FlattenResult8 extension

flatten() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<T>>>>>>>, provided by the FlattenResult7 extension

flatten() Result<T>

Available on Result<Result<Result<Result<Result<Result<T>>>>>>, provided by the FlattenResult6 extension

flatten() Result<T>

Available on Result<Result<T>>, provided by the FlattenResult2 extension

flatten() Result<T>

Available on Result<Result<Result<T>>>, provided by the FlattenResult3 extension

flatten() Result<T>

Available on Result<Result<Result<Result<T>>>>, provided by the FlattenResult4 extension

flatten2() Result<T>

Available on Result<Result<T>>, provided by the FlattenResult2 extension

flatten3() Result<T>

Available on Result<Result<Result<T>>>, provided by the FlattenResult3 extension

flatten4() Result<T>

Available on Result<Result<Result<Result<T>>>>, provided by the FlattenResult4 extension

flatten5() Result<T>

Available on Result<Result<Result<Result<Result<T>>>>>, provided by the FlattenResult5 extension

flatten6() Result<T>

Available on Result<Result<Result<Result<Result<Result<T>>>>>>, provided by the FlattenResult6 extension

flatten7() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<T>>>>>>>, provided by the FlattenResult7 extension

flatten8() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<Result<T>>>>>>>>, provided by the FlattenResult8 extension

flatten9() Result<T>

Available on Result<Result<Result<Result<Result<Result<Result<Result<Result<T>>>>>>>>>, provided by the FlattenResult9 extension

fold(Result<Object>? onOk(Ok<T> ok), Result<Object>? onErr(Err<T> err)) Result<Object>
Folds the two cases of this Result into a single new Result.
ifErr(void noFuturesAllowed(Err<T> err)) Result<T>
Performs a side-effect with the contained error if this is an Err.
ifOk(void noFuturesAllowed(Ok<T> ok)) Result<T>
Performs a side-effect with the contained value if this is an Ok.
isErr() bool
Returns true if this Result is an Err.
isOk() bool
Returns true if this Result is an Ok.
map<R extends Object>(R noFuturesAllowed(T value)) Result<R>
Transforms the contained value using the mapper function noFuturesAllowed while preserving the Monad's structure.
override
map10<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>, provided by the MapMonad10 extension

map11<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>, provided by the MapMonad11 extension

map12<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>, provided by the MapMonad12 extension

map13<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>, provided by the MapMonad13 extension

map14<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>>, provided by the MapMonad14 extension

map15<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>>>, provided by the MapMonad15 extension

map16<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>>>>, provided by the MapMonad16 extension

map17<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>>>>>, provided by the MapMonad17 extension

map18<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>>>>>>>>>, provided by the MapMonad18 extension

map2<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Object>>, provided by the MapMonad2 extension

map3<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Object>>>, provided by the MapMonad3 extension

map4<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Object>>>>, provided by the MapMonad4 extension

map5<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Object>>>>>, provided by the MapMonad5 extension

map6<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>, provided by the MapMonad6 extension

map7<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>, provided by the MapMonad7 extension

map8<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>, provided by the MapMonad8 extension

map9<R extends Object>(R mapper(T)) TReduced<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>, provided by the MapMonad9 extension

mapErr(Err<T> noFuturesAllowed(Err<T> err)) Result<T>
Transforms the inner Err instance if this is an Err.
mapOk(Ok<T> noFuturesAllowed(Ok<T> ok)) Result<T>
Transforms the inner Ok instance if this is an Ok.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ok() Option<Ok<T>>
Safely gets the Ok instance. Returns a Some on Ok, or a None on Err.
okOr(Result<T> other) Result<T>
Returns this if it's Ok, otherwise returns the other Result.
orNull() → T?
Returns the contained Ok value or null.
reduce<R extends Object>() Resolvable<Option<R>>
Reduces the monad to a Resolvable of an Option of type R.
inherited
swap() Resolvable<Result<T>>

Available on Result<Resolvable<T>>, provided by the ResultResolvableSwapX extension

swap() Ok<Result<T>>

Available on Result<Ok<T>>, provided by the ResultOkSwapX extension

swap() Option<Result<T>>

Available on Result<Option<T>>, provided by the ResultOptionSwapX extension

swap() Sync<Result<T>>

Available on Result<Sync<T>>, provided by the ResultSyncSwapX extension

swap() Some<Result<T>>

Available on Result<Some<T>>, provided by the ResultSomeSwapX extension

swap() Async<Result<T>>

Available on Result<Async<T>>, provided by the ResultAsyncSwapX extension

swap() Result<T>

Available on Result<Err<T>>, provided by the ResultErrSwapX extension

swap() Option<Result<T>>

Available on Result<None<T>>, provided by the ResultNoneSwapX extension

toString() String
A string representation of this object.
inherited
toUnit() Monad<Unit>

Available on Monad<Object>, provided by the ToUnitOnObjectMonad extension

toUnit() Result<Unit>

Available on Result<Object>, provided by the ToUnitOnObjectResult extension

transf<R extends Object>([R noFuturesAllowed(T e)?]) Result<R>
Transforms the Monad's generic type from T to R.
override
unwrap() → T
Unsafely returns the contained value. Throws Err the Monad is an Err or None.
override
unwrapOr(T fallback) → T
Returns the contained value, or the fallback if the Monad is in an Err or None state.
override
wrapAsync() Async<Result<T>>
Wraps this Monad in an Async.
override
wrapOk() Ok<Result<T>>
Wraps this Monad in an Ok.
override
wrapResolvable() Resolvable<Result<T>>
Wraps this Monad in a Resolvable.
override
wrapSome() Some<Result<T>>
Wraps this Monad in a Some.
override
wrapSync() Sync<Result<T>>
Wraps this Monad in a Sync.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

zip2<T1 extends Object, T2 extends Object>(Result<T1> r1, Result<T2> r2, [Err<(T1, T2)> onErr(Result<T1>, Result<T2>)?]) Result<(T1, T2)>
Combines 2 Result monads into 1 containing a tuple of their values if all are Ok.
zip3<T1 extends Object, T2 extends Object, T3 extends Object>(Result<T1> r1, Result<T2> r2, Result<T3> r3, [Err<(T1, T2, T3)> onErr(Result<T1>, Result<T2>, Result<T3>)?]) Result<(T1, T2, T3)>
Combines 3 Result monads into 1 containing a tuple of their values if all are Ok.