takeIf method

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

如果test返回true则返回对象本身, 否则返回null

Implementation

T? takeIf(bool Function(T it) test) => test.call(this) ? this : null;