flush method
Flushes the stream.
If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
Example
final writer = BufferedWriter(FileWriter('output.txt'));
try {
await writer.write('Important data');
await writer.flush(); // Ensure data is written immediately
// Continue with more operations...
await writer.write('More data');
} finally {
await writer.close(); // close() also flushes
}
Throws IOException if an I/O error occurs. Throws StreamClosedException if the writer has been closed.
Implementation
@override
Future<void> flush() async {
checkClosed();
// Default implementation does nothing
}