takeUnless method
Returns this
value if it does not satisfy the given predicate test
or null
if it does.
Example:
int? number = 5.takeUnless((it) => it > 6);
print(number); // Output: 5
number = 5.takeUnless((it) => it > 3);
print(number); // Output: null
Implementation
T? takeUnless(bool Function(T it) test) => !test(this) ? this : null;