takeIf method

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

Implementation

T? takeIf(bool Function(T self) predicate) {
  if (predicate(this)) {
    return this;
  } else {
    return null;
  }
}