andThen<R> abstract method

Option<R> andThen<R>(
  1. Option<R> next(
    1. T value
    )
)

Chains another option-producing operation when a value is present.

Option<int> parseCount(String text) {
  final value = int.tryParse(text);
  return value == null ? const None<int>() : Some(value);
}

final parsed = const Some<String>('42').andThen(parseCount);

Implementation

Option<R> andThen<R>(Option<R> Function(T value) next);