when<T, R> static method

R? Function(T) when<T, R>(
  1. bool predicate(
    1. T
    ),
  2. R action(
    1. T
    )
)

Implementation

static R? Function(T) when<T, R>(
  bool Function(T) predicate,
  R Function(T) action,
) {
  return (T input) => predicate(input) ? action(input) : null;
}