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
Properties
- errorOrNull → E?
-
Available on Either<
The validation error, orE, T> , provided by the GmanaValueObjectResultX extensionnullwhen validation succeeded.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- isInvalid → bool
-
Available on ValidationResult<
Whether validation failed.TIssue, TValue> , provided by the GmanaValidationResultX extensionno setter - isInvalid → bool
-
Available on Either<
Whether validation failed.E, T> , provided by the GmanaValueObjectResultX extensionno setter - issueOrNull → TIssue?
-
Available on ValidationResult<
The typed validation issue, orTIssue, TValue> , provided by the GmanaValidationResultX extensionnullwhen validation succeeded.no setter - isValid → bool
-
Available on ValidationResult<
Whether validation succeeded.TIssue, TValue> , provided by the GmanaValidationResultX extensionno setter - isValid → bool
-
Available on Either<
Whether validation succeeded.E, T> , provided by the GmanaValueObjectResultX extensionno 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<
The validated value, orTIssue, TValue> , provided by the GmanaValidationResultX extensionnullwhen validation failed.no setter - valueOrNull → T?
-
Available on Either<
The validated value, orE, T> , provided by the GmanaValueObjectResultX extensionnullwhen validation failed.no setter
Methods
-
all(
bool test(R right)) → bool -
Returns
truewhen this is a Left or whentestpasses for the Right value.inherited -
bimap<
L2, R2> (L2 ifLeft(L left), R2 ifRight(R right)) → Either< L2, R2> -
Applies
ifLeftorifRightand returns a new Either with mapped values.override -
contains(
R value) → bool -
Returns
truewhen this is a Right containingvalue.inherited -
exists(
bool test(R right)) → bool -
Returns
truewhen this is a Right andtestpasses.inherited -
filterOrElse(
bool test(R right), L onFalse(R right)) → Either< L, R> -
Demotes a Right to a Left when
testfails.inherited -
flatMap<
R2> (Either< L, R2> f(R right)) → Either<L, R2> -
Applies the given function
fto the contained value, and flattens the result.override -
flatMapAsync<
R2> (FutureOr< Either< f(R right)) → Future<L, R2> >Either< L, R2> > -
Asynchronously applies
fto 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
ifRightto 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
defaultValuewhen 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
falsebecause this is a Right.override -
isRight(
) → bool -
Always returns
truebecause 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<
Resolves the validation error to a message, or returnsE, T> , provided by the GmanaValueObjectResultX extensionnullon success. -
messageOrNull(
ValidationMessageResolver< TIssue> resolve) → String? -
Available on ValidationResult<
Resolves the validation issue to a message, or returnsTIssue, TValue> , provided by the GmanaValidationResultX extensionnullon 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
fwith the Right value, if present, and returns this Either.inherited -
tapLeft(
void f(L left)) → Either< L, R> -
Runs
fwith the Left value, if present, and returns this Either.inherited -
toEmailDomainResult(
) → Either< EmailError, Email> -
Available on Either<
Converts this validation result to a domain Email result with EmailError.EmailValidationIssue, String> , provided by the EmailValidationAdapterX extension -
toEmailValueObject(
) → Either< EmailValidationIssue, Email> -
Available on Either<
Converts a successful validation into an Email value object.EmailValidationIssue, String> , provided by the EmailValidationAdapterX extension -
toIdentifierDomainResult(
) → Either< IdentifierError, IdentifierValue> -
Available on Either<
Converts this validation result to a domain IdentifierValue result with IdentifierError.IdentifierValidationIssue, String> , provided by the IdentifierValidationAdapterX extension -
toIdentifierValueObject(
) → Either< IdentifierValidationIssue, IdentifierValue> -
Available on Either<
Converts a successful validation into an IdentifierValue value object.IdentifierValidationIssue, String> , provided by the IdentifierValidationAdapterX extension -
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<
Converts this validation result to a domain NetworkAddressValue result with NetworkAddressError.NetworkValidationIssue, String> , provided by the NetworkValidationAdapterX extension -
toNetworkAddressValueObject(
) → Either< NetworkValidationIssue, NetworkAddressValue> -
Available on Either<
Converts a successful validation into a NetworkAddressValue value object.NetworkValidationIssue, String> , provided by the NetworkValidationAdapterX extension -
toNumberDomainResult(
) → Either< NumberError, NumberValue> -
Available on Either<
Converts this validation result to a domain NumberValue result with NumberError.NumberValidationIssue, num> , provided by the NumberValidationAdapterX extension -
toNumberValueObject(
) → Either< NumberValidationIssue, NumberValue> -
Available on Either<
Converts a successful validation into a NumberValue value object.NumberValidationIssue, num> , provided by the NumberValidationAdapterX extension -
toOption(
) → Option< R> -
Discards the Left value, keeping only whether a Right was present.
inherited
-
toPasswordDomainResult(
) → Either< PasswordError, Password> -
Available on Either<
Converts this validation result to a domain Password result with PasswordError.PasswordValidationIssue, String> , provided by the PasswordValidationAdapterX extension -
toPasswordValueObject(
) → Either< PasswordValidationIssue, Password> -
Available on Either<
Converts a successful validation into a Password value object.PasswordValidationIssue, String> , provided by the PasswordValidationAdapterX extension -
toPhoneDomainResult(
) → Either< PhoneError, PhoneValue> -
Available on Either<
Converts this validation result to a domain PhoneValue result with PhoneError.PhoneValidationIssue, String> , provided by the PhoneValidationAdapterX extension -
toPhoneValueObject(
) → Either< PhoneValidationIssue, PhoneValue> -
Available on Either<
Converts a successful validation into a PhoneValue value object.PhoneValidationIssue, String> , provided by the PhoneValidationAdapterX extension -
toResult(
) → GResult< R, L> -
Available on Either<
Converts this Either to a GResult, mapping Left to GFailure and Right to GSuccess.L, R> , provided by the GmanaEitherToResultX extension -
toString(
) → String -
A string representation of this object.
override
-
toTextDomainResult(
) → Either< TextError, TextValue> -
Available on Either<
Converts this validation result to a domain TextValue result with TextError.TextValidationIssue, String> , provided by the TextValidationAdapterX extension -
toTextValueObject(
) → Either< TextValidationIssue, TextValue> -
Available on Either<
Converts a successful validation into a TextValue value object.TextValidationIssue, String> , provided by the TextValidationAdapterX extension -
toUrlDomainResult(
) → Either< UrlError, UrlValue> -
Available on Either<
Converts this validation result to a domain UrlValue result with UrlError.UrlValidationIssue, Uri> , provided by the UrlValidationAdapterX extension -
toUrlValueObject(
) → Either< UrlValidationIssue, UrlValue> -
Available on Either<
Converts a successful validation into an UrlValue value object.UrlValidationIssue, Uri> , provided by the UrlValidationAdapterX extension -
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
otherthroughcombine.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override