Properties
-
err
→ Err<T, E>
-
Get the Err value or throw an error if it's Ok.
no setter
-
hashCode
→ int
-
The hash code for this object.
no setteroverride
-
isErr
→ bool
-
no setter
-
isOk
→ bool
-
no setter
-
ok
→ Ok<T, E>
-
Get the Ok value or throw an error if it's Err.
no setter
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
andThen<U>(Result<U, E> fn(T value))
→ Result<U, E>
-
Applies a function to the value inside Ok if it exists, otherwise
returns Err.
-
fold<B>(B onOk(T value), B onErr(E error))
→ B
-
Fold is used to handle both Ok and Err cases.
-
getOrElse(T defaultValue())
→ T
-
If the Result is Ok, provides a default value; otherwise, executes
the error function.
-
isErrAnd(bool predicate(E error))
→ bool
-
Check if Result is Err and the error satisfies a predicate.
-
isOkAnd(bool predicate(T value))
→ bool
-
Check if Result is Ok and the value satisfies a predicate.
-
map<U>(U fn(T value))
→ Result<U, E>
-
Maps the value inside Ok if it exists, keeping Err unchanged.
-
mapAsync<U>(Future<U> fn(T value))
→ Future<Result<U, E>>
-
Maps the value inside Ok asynchronously, keeping Err unchanged.
-
mapErr<F>(F fn(E error))
→ Result<T, F>
-
Maps the error inside Err if it exists, keeping Ok unchanged.
-
mapOrElse<U>(U onOk(T value), U onErr(E error))
→ Result<U, E>
-
If it's Ok, apply the function to the value; otherwise, return the
original Result.
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
orElse(Result<T, E> alternative())
→ Result<T, E>
-
If this Result is Err, provides a default value (or another Result).
-
toOption()
→ Option<T>
-
Convert to Option, where Ok becomes Some and Err becomes None.
-
toString()
→ String
-
A string representation of this object.
inherited
-
unwrap()
→ T
-
Unwrap the value or throw an error if it's Err.