ConversionResult<T> class

Represents the outcome of a conversion, capturing either a value or error.

Constructors

ConversionResult.failure(ConversionException error)
Creates a failed result wrapping error.
factory
ConversionResult.success(T value)
Creates a successful result wrapping value.
factory

Properties

error ConversionException?
The captured ConversionException, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
isFailure bool
Whether this result contains an error.
no setter
isSuccess bool
Whether this result contains a value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Returns the converted value or throws the stored ConversionException.
no setter
valueOrNull → T?
Returns the converted value when successful, otherwise null.
no setter

Methods

flatMap<R>(ConversionResult<R> next(T value)) ConversionResult<R>
Chains conversion results, forwarding failures automatically.
fold<R>({required R onSuccess(T value), required R onFailure(ConversionException error)}) → R
Folds the result into a single value using the supplied callbacks.
map<R>(R transform(T value)) ConversionResult<R>
Transforms the contained value when successful.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
valueOr(T defaultValue) → T
Returns the converted value or defaultValue when a failure occurred.

Operators

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