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<L, R>, provided by the EitherExtensions extension

Returns true if this is a Left.
no setter
isRight → bool

Available on Either<L, R>, provided by the EitherExtensions extension

Returns true if this is a Right.
no setter
left → L?

Available on Either<L, R>, provided by the EitherExtensions extension

Returns the Left value if present, otherwise null.
no setter

Available on Either<L, R>, provided by the EitherExtensions extension

Returns the Right value if present, otherwise null.
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 leftFn if this is a Left, or rightFn if 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