close method Null safety

Future<void> close()

Closes all transformed streams.

Returns a future that completes when all inner subscriptions' StreamSubscription.cancel futures have completed. Note that a stream's subscription won't be canceled until the transformed stream has a listener.

If a transformed stream is listened to after close is called, the original stream will be listened to and then the subscription immediately canceled. If that cancellation throws an error, it will be silently ignored.


Future<void> close() => _closeFuture ??= () {
      var futures = [
        for (var subscription in _subscriptions) subscription.cancel()

      var controllers = _controllers.toList();
      scheduleMicrotask(() {
        for (var controller in controllers) {

      return Future.wait(futures, eagerError: true);