takeIf method

T? takeIf(
  1. bool block(
    1. T it
    )
)

Return the current value if the given block is satisifed, will return null if not.

Implementation

T? takeIf(bool Function(T it) block) {
  if (this != null && block(this!)) {
    return this;
  }
  return null;
}