flatten method

Stream<T?> flatten([
  1. T? initialValue,
  2. bool filterNotNull = true
])

Implementation

Stream<T?> flatten([T? initialValue, bool filterNotNull = true]) {
  final initial = get();

  Stream<T?> base = (initial is Future<T?>)
      ? Stream.fromIterable([initialValue]).merge(Stream.fromFuture(initial))
      : Stream.fromIterable([initial]);

  return filterNotNull
      ? base.followedBy(after).where((_) {
          if (_ == null) {
            _log.fine("Not sending null value for $T stream");
            return true;
          }
          return true;
        })
      : base.followedBy(after);
}