flatMap<R> method

ConversionResult<R> flatMap<R>(
  1. ConversionResult<R> next(
    1. T value
    )
)

Chains another conversion operation when this result is successful.

Unlike map, the next function returns a ConversionResult, allowing composition of fallible operations. Failures short-circuit the chain.

Implementation

ConversionResult<R> flatMap<R>(ConversionResult<R> Function(T value) next) {
  if (isSuccess) {
    return next(_value as T);
  }
  return ConversionResult.failure(_error!);
}