Ok<T, E> class final

Represents a successful value.

Inheritance

Constructors

Ok(T value)
const

Properties

err Err<T, E>
Get the Err value or throw an error if it's Ok.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isErr bool
no setterinherited
isOk bool
no setterinherited
ok Ok<T, E>
Get the Ok value or throw an error if it's Err.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
final

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.
inherited
fold<B>(B onOk(T value), B onErr(E error)) → B
Fold is used to handle both Ok and Err cases.
override
getOrElse(T defaultValue()) → T
If the Result is Ok, provides a default value; otherwise, executes the error function.
inherited
isErrAnd(bool predicate(E error)) bool
Check if Result is Err and the error satisfies a predicate.
inherited
isOkAnd(bool predicate(T value)) bool
Check if Result is Ok and the value satisfies a predicate.
inherited
map<U>(U fn(T value)) Result<U, E>
Maps the value inside Ok if it exists, keeping Err unchanged.
inherited
mapAsync<U>(Future<U> fn(T value)) Future<Result<U, E>>
Maps the value inside Ok asynchronously, keeping Err unchanged.
inherited
mapErr<F>(F fn(E error)) Result<T, F>
Maps the error inside Err if it exists, keeping Ok unchanged.
inherited
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.
inherited
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).
inherited
toOption() Option<T>
Convert to Option, where Ok becomes Some and Err becomes None.
inherited
toString() String
A string representation of this object.
inherited
unwrap() → T
Unwrap the value or throw an error if it's Err.
inherited

Operators

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