Result<T, E> class
An object that can contain either a successful result (of type T), or
an error (of type E).
Use the Result.ok
and Result.error
constructors to create these.
Constructors
- Result({T? object, E? error})
-
const
- Result.error(E error)
-
A failed result.
factory
- Result.ok(T object)
-
A successful result.
factory
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
transform<
X> (Result< X, E> transformer(T? e)) → Result<X, E> -
Transforms a Result<T, E> into a Result<X, E> through
transformer
. If the Result this is called on has an error, it will be passed on, and if it is ok then thetransformer
will be applied. -
transformOk<
X> (X transformer(T? e)) → Result< X, E> -
Transforms a T into an X through
transformer
, and returns a Result.ok containing the X. If the Result this is called on has an error, it will be passed on, and if it is ok then thetransformer
will be applied. -
unwrap(
) → T - Returns the object if it is ok, or throws an UnwrapException if not.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited