Either<L, R> class
sealed
Represents a value of one of two possible types, Left or Right.
The hierarchy is sealed: switch expressions over an Either are checked
for exhaustiveness and can destructure the held value.
final message = switch (result) {
Left(:final value) => 'Failed: $value',
Right(:final value) => 'Got $value',
};
- Implementers
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLeft → bool
-
Available on Either<
ReturnsL, R> , provided by the EitherExtensions extensiontrueif this is a Left.no setter - isRight → bool
-
Available on Either<
ReturnsL, R> , provided by the EitherExtensions extensiontrueif this is a Right.no setter - left → L?
-
Available on Either<
Returns the Left value if present, otherwiseL, R> , provided by the EitherExtensions extensionnull.no setter - right → R?
-
Available on Either<
Returns the Right value if present, otherwiseL, R> , provided by the EitherExtensions extensionnull.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fold<
T> (T leftFn(L l), T rightFn(R r)) → T -
Applies
leftFnif this is a Left, orrightFnif this is a Right. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited