takeUnless method

T? takeUnless(
  1. bool predicate(
    1. T it
    )
)

Returns this value if it does not satisfy the given predicate or null if it does. Used for checking some condition and returning the object itself if it doesn't match the condition. someNullable?.takeUnless((it) => it > 5); // returns someNullable if it is not greater than 5.

Implementation

T? takeUnless(bool Function(T it) predicate) {
  return predicate.call(this) ? null : this;
}