takeIf method

T? takeIf(
  1. bool predicate(
    1. T
    )
)

Implementation

T? takeIf(bool Function(T) predicate) => (predicate(this)) ? this : null;