flatMap<R> method

Result<R> flatMap<R>(
  1. Result<R> f(
    1. T value
    )
)

Chaining: если success — применяет f, если failure — пропускает.

final names = result
  .flatMap((items) => Right(items.map((e) => e.name).toList()))
  .orElse((_) => <String>[]);

Implementation

Result<R> flatMap<R>(Result<R> Function(T value) f) => switch (this) {
  Right(:final value) => f(value),
  Left(:final failure) => Left(failure),
};