flush method

Future flush()

Implementation

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;
  });
}