Either<L, R> class
sealed
A type that represents a value of one of two possible types (a disjoint union).
Instances of Either are either an instance of Left or Right.
By convention, Left is used for failure and Right is used for success.
- Available extensions
- Annotations
-
- @Freezed.new()
Constructors
- Either.left(L value)
-
Represents the left side of the disjoint union (by convention, an error).
constfactory
- Either.right(R value)
-
Represents the right side of the disjoint union (by convention, a success).
constfactory
Properties
Methods
-
fold<
T> (T onLeft(L left), T onRight(R right)) → T -
Folds the Either into a single value, applying
onLeftif this isLeft, andonRightif this isRight. -
map<
TResult extends Object?> ({required TResult left(Left< L, R> value), required TResult right(Right<L, R> value)}) → TResult -
Available on Either<
AL, R> , provided by the EitherPatterns extensionswitch-like method, using callbacks. -
mapLeft<
L2> (L2 combiner(L left)) → Either< L2, R> - Maps the left value, leaving the right value unchanged.
-
mapOrNull<
TResult extends Object?> ({TResult? left(Left< L, R> value)?, TResult? right(Right<L, R> value)?}) → TResult? -
Available on Either<
A variant ofL, R> , provided by the EitherPatterns extensionmapthat fallback to returningnull. -
mapRight<
R2> (R2 combiner(R right)) → Either< L, R2> - Maps the right value, leaving the left value unchanged.
-
maybeMap<
TResult extends Object?> ({TResult left(Left< L, R> value)?, TResult right(Right<L, R> value)?, required TResult orElse()}) → TResult -
Available on Either<
A variant ofL, R> , provided by the EitherPatterns extensionmapthat fallback to returningorElse. -
maybeWhen<
TResult extends Object?> ({TResult left(L value)?, TResult right(R value)?, required TResult orElse()}) → TResult -
Available on Either<
A variant ofL, R> , provided by the EitherPatterns extensionwhenthat fallback to anorElsecallback. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
when<
TResult extends Object?> ({required TResult left(L value), required TResult right(R value)}) → TResult -
Available on Either<
AL, R> , provided by the EitherPatterns extensionswitch-like method, using callbacks. -
whenOrNull<
TResult extends Object?> ({TResult? left(L value)?, TResult? right(R value)?}) → TResult? -
Available on Either<
A variant ofL, R> , provided by the EitherPatterns extensionwhenthat fallback to returningnull
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited