Left<L, R> class
Represents the failure or error side of an Either.
A Left<L, R> contains a value of type L, typically used to represent
an error or exceptional case. This is returned from methods that may fail,
instead of throwing exceptions.
Operations like map and flatMap are no-ops on Left, meaning they
return the same Left unchanged.
Example:
Either<String, int> result = const Left('Something went wrong');
print(result.isLeft()); // true
print(result.isRight()); // false
print(result.getLeft()); // 'Something went wrong'
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → L
-
The encapsulated value, typically representing an error or failure.
final
Methods
-
flatMap<
R2> (Either< L, R2> f(R right)) → Either<L, R2> -
Applies the function
fto the value contained in Right, if it exists, and returns a new Either containing the result. If this is a Left, it is returned unchanged.override -
fold<
B> (B ifLeft(L left), B ifRight(R right)) → B -
Applies one of two functions depending on whether this is a Left or Right.
override
-
getLeft(
) → L -
Returns the Left value if this is a Left, otherwise throws.
override
-
getRight(
) → R -
Returns the Right value if this is a Right, otherwise throws.
override
-
isLeft(
) → bool -
Returns
trueif this is a Left.override -
isRight(
) → bool -
Returns
trueif this is a Right.override -
map<
R2> (R2 f(R right)) → Either< L, R2> -
Transforms the value contained in Right using the given function
f, returning a new Either with the transformed value.override -
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