takeIf method
Returns this
value if it satisfies the given predicate
or null
, if it doesn't.
Implementation
@pragma('vm:prefer-inline')
@pragma('dart2js:tryInline')
@experimental
T? takeIf(bool Function(T) predicate) {
if (predicate(this as T)) return this as T;
return null;
}