Result<T, E> class abstract

Result is a type that represents either success (Ok) or failure (Err).

Implementers
Available Extensions
Annotations
  • @sealed

Constructors

Result()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
isErr bool
Returns true if the result is Err.
no setter
isOk bool
Returns true if the result is Ok.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

and<U>(Result<U, E> res) Result<U, E>
Returns res if the result is Ok, otherwise returns the Err value of this.
andThen<U>(Result<U, E> op(T value)) Result<U, E>
Calls op if the result is Ok, otherwise returns the Err value of this.
err() → E?
Converts from Result<T, E> to E?.
errOpt() Option<E>
Converts from Result<T, E> to Option<E>.
expect(String msg) → T
Returns the contained Ok value, consuming the this value.
expectErr(String msg) → E
Returns the contained Err value, consuming the this value.
iter() Iterable<T>
Returns an iterable over the possibly contained value.
map<U>(U op(T value)) Result<U, E>
Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched.
mapErr<F>(F op(E err)) Result<T, F>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.
mapOr<U>(U defaultValue, U f(T value)) → U
Returns the provided default (if Err), or applies a function to the contained value (if Ok),
mapOrElse<U>(U defaultF(E err), U f(T value)) → U
Maps a Result<T, E> to U by applying fallback function defaultF to a contained Err value, or function f to a contained Ok value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ok() → T?
Converts from Result<T, E> to T?.
okOpt() Option<T>
Converts from Result<T, E> to Option<T>.
or<F>(Result<T, F> res) Result<T, F>
Returns res if the result is Err, otherwise returns the Ok value of this.
orElse<F>(Result<T, F> op(E err)) Result<T, F>
Calls op if the result is Err, otherwise returns the Ok value of this.
toString() String
A string representation of this object.
inherited
unwrap() → T
Returns the contained Ok value, consuming the this value.
unwrapErr() → E
Returns the contained Err value, consuming the this value.
unwrapOr(T defaultValue) → T
Returns the contained Ok value or a provided default.
unwrapOrElse(T op(E err)) → T
Returns the contained Ok value or computes it from a closure.

Operators

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