Either<L, R> class
abstract
Either is an entity whose value can be of two different types, called left and right. By convention, Right is for the success case and Left for the error one.
- Implementers
- Available Extensions
Constructors
- Either()
- Either is an entity whose value can be of two different types, called left and right. By convention, Right is for the success case and Left for the error one.
- Either.condition({required bool test, required L leftValue, required R rightValue})
-
If the condition is test then return
rightValue
in Right elseleftValue
in Leftfactory -
Either.conditionLazy({required bool test, required LazyCallback<
L> leftValue, required LazyCallback<R> rightValue}) -
If the condition is test then return lazy
rightValue
in Right else lazyleftValue
in Leftfactory - Either.left(L value)
-
Constructs a new Either from a Left
factory
-
Either.leftLazy(LazyCallback<
L> value) -
Lazy constructs a new Either from a Left
factory
- Either.right(R value)
-
Constructs a new Either from a Right
factory
-
Either.rightLazy(LazyCallback<
R> value) -
Lazy constructs a new Either from a Right
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLeft → bool
-
Represents the left side of Either class which by convention is a "Failure".
no setter
- isRight → bool
-
Represents the right side of Either class which by convention is a "Success"
no setter
- left → L
-
A Left value
no setter
- right → R
-
A Right value
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cast<
F, S> () → Either< F, S> - Cast to new Left & Right type
-
either(
{required EitherCallback< L> onLeft, required EitherCallback<R> onRight}) → void - Either type result on Callback
-
map(
{required MapCallback< L> onLeft, required MapCallback<R> onRight}) → Either<L, R> - Return the Either result in one of these functions.
-
mapAsync(
{required AsyncMapCallback< L> onLeft, required AsyncMapCallback<R> onRight}) → Future<Either< L, R> > -
Return the async
Either
result in one of these async functions. -
maybeWhen<
T> ({WhenCallback< T, L> ? onLeft, WhenCallback<T, R> ? onRight, required MaybeCallback<T> orElse}) → T -
The maybeWhen method is equivalent to when, but doesn't require all callbacks to be specified.
On the other hand, it adds an extra
orElse
required parameter, for fallback behavior. -
maybeWhenAsync<
T> ({AsyncWhenCallback< T, L> ? onLeft, AsyncWhenCallback<T, R> ? onRight, required AsyncMaybeCallback<T> orElse}) → Future<T> -
The maybeWhenAsync method is equivalent to whenAsync, but doesn't require all callbacks to be specified.
On the other hand, it adds an extra
orElse
required parameter, for fallback behavior. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
swap(
) → Either< R, L> - Swap Left and Right
-
toString(
) → String -
A string representation of this object.
inherited
-
when<
T> ({required WhenCallback< T, L> onLeft, required WhenCallback<T, R> onRight}) → T - Return the result in one of these functions.
-
whenAsync<
T> ({required AsyncWhenCallback< T, L> onLeft, required AsyncWhenCallback<T, R> onRight}) → Future<T> - Return the async result in one of these async functions.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
tryCatch<
L, R> (MaybeCallback< R> onRight) → Either<L, R> - Constructs a new Either from a function that might throw