disconnect method Null safety

Future<void> disconnect()

Disconnects all channels that have been transformed.

Returns a future that completes when all inner sinks' StreamSink.close futures have completed. Note that a StreamController's sink won't close until the corresponding stream has a listener.

Implementation

Future<void> disconnect() => _disconnectMemo.runOnce(() {
      var futures = _sinks.map((sink) => sink._disconnect()).toList();
      _sinks.clear();
      return Future.wait(futures, eagerError: true);
    });