takeIf method
Returns value if it satisfies the predicate, otherwise null Usage: number.takeIf((it) => it > 0)
Implementation
T? takeIf(bool Function(T it) predicate) {
final self = this;
if (self != null) {
return predicate(self) ? this : null;
}
return null;
}