Right<L, R> class

A concrete implementation of Either that represents the successful value (Right) in a computation.

Commonly used in functional programming to wrap a successful result, while the Left represents a failure or error.

Example usage:

Either<String, int> result = Right(42);
print(result.isRight()); // true
Inheritance

Constructors

Right(R value)
Creates a Right instance with the given value.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → R
The successful value held by this Right.
final

Methods

bimap<L2, R2>(L2 ifLeft(L left), R2 ifRight(R right)) Either<L2, R2>
Applies ifLeft or ifRight and returns a new Either with mapped values.
override
flatMap<R2>(Either<L, R2> f(R right)) Either<L, R2>
Applies the given function f to the contained value, and flattens the result.
override
fold<B>(B ifLeft(L left), B ifRight(R right)) → B
Applies ifRight to the contained value and returns its result.
override
getLeft() → L
Throws a StateError because this is a Right and does not contain a Left value.
override
getOrElse(R orElse(L left)) → R
Returns the Right value if this is a Right, otherwise computes a fallback.
inherited
getRight() → R
Returns the contained value.
override
isLeft() bool
Always returns false because this is a Right.
override
isRight() bool
Always returns true because this is a Right.
override
leftOrNull() → L?
Returns the Left value if this is a Left, otherwise null.
override
map<R2>(R2 f(R right)) Either<L, R2>
Transforms the contained value using the provided function f, returning a new Right.
override
mapLeft<L2>(L2 f(L left)) Either<L2, R>
Maps the Left value using f, if present.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rightOrNull() → R?
Returns the Right value if this is a Right, otherwise null.
override
swap() Either<R, L>
Swaps the sides of this Either, turning Left into Right and vice versa.
override
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override