Either<L, R> class
sealed
A disjoint union with a value of either type L
or type R
.
- Annotations
-
- @immutable
Constructors
-
Either.either(Map0<
L?> leftProvider, Map0<R?> rightProvider) -
Creates a left-biased Either. This means, if the
leftProvider
returns a non-null value create a left-sided Either. Alternatively, if therightProvider
returns a non-null value, create a right-sided Either. Otherwise, if both providers return a null-value, throw a StateError.factory -
Either.iff(bool condition, Map0<
L> leftProvider, Map0<R> rightProvider) -
Creates an left-sided Either from the
leftProvider
, ifcondition
istrue
. Otherwise, create a right-sided Either from therightProvider
.factory - Either.left(L value)
-
Creates an Either with the left value populated.
constfactory
- Either.right(R value)
-
Creates an Either with the right value populated.
constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLeft → bool
-
Returns
true
, if this is a left value.no setter - isRight → bool
-
Returns
true
, if this has a right value.no setter -
leftOptional
→ Optional<
L> -
Returns the left value as an Optional.
no setter
- leftValue → L
-
Returns the left value, if absent throws a StateError.
no setter
-
rightOptional
→ Optional<
R> -
Returns the right value as an Optional.
no setter
- rightValue → R
-
Returns the right value, if absent throws a StateError.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tuple → (L?, R?)
-
Returns a tuple with either the left or right value defined.
no setter
- value → dynamic
-
Returns a dynamically typed value of this object, either the leftValue
or the rightValue.
no setter
Methods
-
flatMap<
L2, R2> (Map1< L, Either< leftFunction, Map1<L2, R2> >R, Either< rightFunction) → Either<L2, R2> >L2, R2> -
Returns a new Either created by the either-returning transformation
leftFunction
orrightFunction
. -
flatMapLeft<
L2> (Map1< L, Either< leftFunction) → Either<L2, R> >L2, R> -
Returns a new Either from the either-returning transformation
leftFunction
, otherwise returns the wrapped right value. -
flatMapRight<
R2> (Map1< R, Either< rightFunction) → Either<L, R2> >L, R2> -
Returns a new Either from the either-returning transformation
rightFunction
, otherwise returns the wrapped left value. -
fold<
T> (Map1< L, T> leftFunction, Map1<R, T> rightFunction) → T -
Returns the appropriate transformation to type
T
. -
map<
L2, R2> (Map1< L, L2> leftFunction, Map1<R, R2> rightFunction) → Either<L2, R2> -
Transforms the left value with
leftFunction
or the right value withrightFunction
. The resulting Either contains the transformed value of the corresponding function. -
mapLeft<
L2> (Map1< L, L2> leftFunction) → Either<L2, R> -
Transforms the left value with
leftFunction
. If applicable, the resulting Either contains the transformed left value. -
mapRight<
R2> (Map1< R, R2> rightFunction) → Either<L, R2> -
Transforms the right value with
rightFunction
. If applicable, the resulting Either contains the transformed right value. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
swap(
) → Either< R, L> - Returns a new Either with the left and right value switched.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited