in lib/src/copy/io_sink.dart [47:64]
Future addStream(Stream<T> stream) {
if (_isBound) {
throw StateError('StreamSink is already bound to a stream');
}
if (_hasError) return done;
_isBound = true;
final future = _controllerCompleter == null
? _target.addStream(stream)
: _controllerCompleter!.future.then((_) => _target.addStream(stream));
_controllerInstance?.close();
// Wait for any pending events in [_controller] to be dispatched before
// adding [stream].
return future.whenComplete(() {
_isBound = false;
});
}