whereNotNull method

Stream<T> whereNotNull()

Returns a Stream which emits all the non-null elements of this Stream, in their original emission order.

For a Stream<T?>, this method is equivalent to .whereType<T>().

Example

Stream.fromIterable(<int?>[1, 2, 3, null, 4, null])
  .whereNotNull()
  .listen(print); // prints 1, 2, 3, 4

// equivalent to:

Stream.fromIterable(<int?>[1, 2, 3, null, 4, null])
  .whereType<int>()
  .listen(print); // prints 1, 2, 3, 4

Implementation

Stream<T> whereNotNull() => WhereNotNullStreamTransformer<T>().bind(this);