Future flush()

in lib/src/copy/io_sink.dart [66:79]


  Future flush() {
    if (_isBound) {
      throw StateError('StreamSink is bound to a stream');
    }
    if (_controllerInstance == null) return Future.value(this);
    // Adding an empty stream-controller will return a future that will complete
    // when all data is done.
    _isBound = true;
    final future = _controllerCompleter!.future;
    _controllerInstance!.close();
    return future.whenComplete(() {
      _isBound = false;
    });
  }