whereNotNull method
Returns the non-null elements as an Iterable<T>.
Unlike whereType<T>(), the element type is recovered as the
non-nullable T directly, so callers do not need a separate cast.
Lazy: nothing runs until the result is iterated.
Example:
[1, null, 3].whereNotNull(); // (1, 3)
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
Iterable<T> whereNotNull() sync* {
for (final T? element in this) {
if (element != null) {
yield element;
}
}
}