takeIf method
Returns the receiver if non-null and satisfies predicate, otherwise null.
Implementation
T? takeIf(bool Function(T it) predicate) {
final value = this;
if (value == null) return null;
return predicate(value) ? value : null;
}
Returns the receiver if non-null and satisfies predicate, otherwise null.
T? takeIf(bool Function(T it) predicate) {
final value = this;
if (value == null) return null;
return predicate(value) ? value : null;
}