takeIfLazy method
Returns this value if predicate returns true for it, otherwise null.
A lazy predicate-based check that evaluates the condition using the value itself. Useful for conditional filtering based on the value's properties.
Example:
final validAge = age.takeIfLazy((a) => a >= 18 && a <= 120);
Implementation
T? takeIfLazy(bool Function(T value) predicate) {
if (predicate(this)) return this;
return null;
}