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
Available extensions
Annotations
  • @immutable

Constructors

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

Properties

errorOrNull → E?

Available on Either<E, T>, provided by the GmanaValueObjectResultX extension

The validation error, or null when validation succeeded.
no setter
hashCode → int
The hash code for this object.
no setteroverride
isInvalid → bool

Available on ValidationResult<TIssue, TValue>, provided by the GmanaValidationResultX extension

Whether validation failed.
no setter
isInvalid → bool

Available on Either<E, T>, provided by the GmanaValueObjectResultX extension

Whether validation failed.
no setter
issueOrNull → TIssue?

Available on ValidationResult<TIssue, TValue>, provided by the GmanaValidationResultX extension

The typed validation issue, or null when validation succeeded.
no setter
isValid → bool

Available on ValidationResult<TIssue, TValue>, provided by the GmanaValidationResultX extension

Whether validation succeeded.
no setter
isValid → bool

Available on Either<E, T>, provided by the GmanaValueObjectResultX extension

Whether validation succeeded.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → R
The successful value held by this Right.
final
valueOrNull → TValue?

Available on ValidationResult<TIssue, TValue>, provided by the GmanaValidationResultX extension

The validated value, or null when validation failed.
no setter
valueOrNull → T?

Available on Either<E, T>, provided by the GmanaValueObjectResultX extension

The validated value, or null when validation failed.
no setter

Methods

all(bool test(R right)) → bool
Returns true when this is a Left or when test passes for the Right value.
inherited
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
contains(R value) → bool
Returns true when this is a Right containing value.
inherited
exists(bool test(R right)) → bool
Returns true when this is a Right and test passes.
inherited
filterOrElse(bool test(R right), L onFalse(R right)) → Either<L, R>
Demotes a Right to a Left when test fails.
inherited
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
flatMapAsync<R2>(FutureOr<Either<L, R2>> f(R right)) → Future<Either<L, R2>>
Asynchronously applies f to the Right value, if present.
override
flatMapLeft<L2>(Either<L2, R> f(L left)) → Either<L2, R>
Chains on the Left side — the mirror of flatMap.
inherited
fold<B>(B ifLeft(L left), B ifRight(R right)) → B
Applies ifRight to the contained value and returns its result.
override
foldAsync<B>(FutureOr<B> ifLeft(L left), FutureOr<B> ifRight(R right)) → Future<B>
Asynchronously applies one of two functions depending on the side present.
inherited
getLeft() → L
Throws a StateError because this is a Right and does not contain a Left value.
override
getOrDefault(R defaultValue) → R
Returns the Right value, or defaultValue when this is a Left.
inherited
getOrElse(R orElse(L left)) → R
Returns the Right value if this is a Right, otherwise computes a fallback.
inherited
getOrNull() → R?
Returns the Right value if this is a Right, otherwise null.
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
mapAsync<R2>(FutureOr<R2> f(R right)) → Future<Either<L, R2>>
Asynchronously transforms the Right value using f, if present.
override
mapLeft<L2>(L2 f(L left)) → Either<L2, R>
Maps the Left value using f, if present.
override
messageOrNull([ValidationErrorMessages messages = const DefaultValidationErrorMessages()]) → String?

Available on Either<E, T>, provided by the GmanaValueObjectResultX extension

Resolves the validation error to a message, or returns null on success.
messageOrNull(ValidationMessageResolver<TIssue> resolve) → String?

Available on ValidationResult<TIssue, TValue>, provided by the GmanaValidationResultX extension

Resolves the validation issue to a message, or returns null on success.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(Either<L, R> f(L left)) → Either<L, R>
Returns this Either when it is a Right, otherwise the result of f.
inherited
orElseWith<L2>(Either<L2, R> f(L left)) → Either<L2, R>
Like orElse but the recovery may produce a different Left type.
inherited
recover(R f(L left)) → Either<L, R>
Turns a Left into a Right by computing a fallback value.
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
tap(void f(R right)) → Either<L, R>
Runs f with the Right value, if present, and returns this Either.
inherited
tapLeft(void f(L left)) → Either<L, R>
Runs f with the Left value, if present, and returns this Either.
inherited
toEmailDomainResult() → Either<EmailError, Email>

Available on Either<EmailValidationIssue, String>, provided by the EmailValidationAdapterX extension

Converts this validation result to a domain Email result with EmailError.
toEmailValueObject() → Either<EmailValidationIssue, Email>

Available on Either<EmailValidationIssue, String>, provided by the EmailValidationAdapterX extension

Converts a successful validation into an Email value object.
toIdentifierDomainResult() → Either<IdentifierError, IdentifierValue>

Available on Either<IdentifierValidationIssue, String>, provided by the IdentifierValidationAdapterX extension

Converts this validation result to a domain IdentifierValue result with IdentifierError.
toIdentifierValueObject() → Either<IdentifierValidationIssue, IdentifierValue>

Available on Either<IdentifierValidationIssue, String>, provided by the IdentifierValidationAdapterX extension

Converts a successful validation into an IdentifierValue value object.
toList() → List<R>
A single-element list for a Right, or an empty list for a Left.
inherited
toNetworkAddressDomainResult() → Either<NetworkAddressError, NetworkAddressValue>

Available on Either<NetworkValidationIssue, String>, provided by the NetworkValidationAdapterX extension

Converts this validation result to a domain NetworkAddressValue result with NetworkAddressError.
toNetworkAddressValueObject() → Either<NetworkValidationIssue, NetworkAddressValue>

Available on Either<NetworkValidationIssue, String>, provided by the NetworkValidationAdapterX extension

Converts a successful validation into a NetworkAddressValue value object.
toNumberDomainResult() → Either<NumberError, NumberValue>

Available on Either<NumberValidationIssue, num>, provided by the NumberValidationAdapterX extension

Converts this validation result to a domain NumberValue result with NumberError.
toNumberValueObject() → Either<NumberValidationIssue, NumberValue>

Available on Either<NumberValidationIssue, num>, provided by the NumberValidationAdapterX extension

Converts a successful validation into a NumberValue value object.
toOption() → Option<R>
Discards the Left value, keeping only whether a Right was present.
inherited
toPasswordDomainResult() → Either<PasswordError, Password>

Available on Either<PasswordValidationIssue, String>, provided by the PasswordValidationAdapterX extension

Converts this validation result to a domain Password result with PasswordError.
toPasswordValueObject() → Either<PasswordValidationIssue, Password>

Available on Either<PasswordValidationIssue, String>, provided by the PasswordValidationAdapterX extension

Converts a successful validation into a Password value object.
toPhoneDomainResult() → Either<PhoneError, PhoneValue>

Available on Either<PhoneValidationIssue, String>, provided by the PhoneValidationAdapterX extension

Converts this validation result to a domain PhoneValue result with PhoneError.
toPhoneValueObject() → Either<PhoneValidationIssue, PhoneValue>

Available on Either<PhoneValidationIssue, String>, provided by the PhoneValidationAdapterX extension

Converts a successful validation into a PhoneValue value object.
toResult() → GResult<R, L>

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

Converts this Either to a GResult, mapping Left to GFailure and Right to GSuccess.
toString() → String
A string representation of this object.
override
toTextDomainResult() → Either<TextError, TextValue>

Available on Either<TextValidationIssue, String>, provided by the TextValidationAdapterX extension

Converts this validation result to a domain TextValue result with TextError.
toTextValueObject() → Either<TextValidationIssue, TextValue>

Available on Either<TextValidationIssue, String>, provided by the TextValidationAdapterX extension

Converts a successful validation into a TextValue value object.
toUrlDomainResult() → Either<UrlError, UrlValue>

Available on Either<UrlValidationIssue, Uri>, provided by the UrlValidationAdapterX extension

Converts this validation result to a domain UrlValue result with UrlError.
toUrlValueObject() → Either<UrlValidationIssue, UrlValue>

Available on Either<UrlValidationIssue, Uri>, provided by the UrlValidationAdapterX extension

Converts a successful validation into an UrlValue value object.
zip<R2>(Either<L, R2> other) → Either<L, (R, R2)>
Pairs the Right values of this and other.
inherited
zipWith<R2, R3>(Either<L, R2> other, R3 combine(R first, R2 second)) → Either<L, R3>
Combines the Right values of this and other through combine.
inherited

Operators

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