# flush method

1. @override

Future<void> flush()
override

Flushes this output stream and forces any buffered output bytes to be written out.

The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

## Example

    final output = BufferedOutputStream(FileOutputStream('output.txt'));
    try {
      await output.writeString('Important data');
      await output.flush(); // Ensure data is written immediately

      // Continue with more operations...
      await output.writeString('More data');
    } finally {
      await output.close(); // close() also flushes
    }

Throws IOException if an I/O error occurs. Throws StreamClosedException if the stream has been closed.

## Implementation

    @override
    Future<void> flush() async {
      checkClosed();

      await _flushBuffer();
      await _output.flush();
    }