takeIf method
Returns this value if predicate is true, otherwise null.
score.takeIf((s) => s >= 60) // score or null
Implementation
T? takeIf(bool Function(T) predicate) => predicate(this) ? this : null;
Returns this value if predicate is true, otherwise null.
score.takeIf((s) => s >= 60) // score or null
T? takeIf(bool Function(T) predicate) => predicate(this) ? this : null;