flush method
Flushes the buffer and ensures all data is written to the underlying writer.
This method is called automatically when the buffer is full or when close is called. It's also a good practice to call this method before reading from the stream to ensure all data is written.
Implementation
@override
Future<void> flush() async {
if (_position > 0) {
await _writer.writeChars(_buffer, 0, _position);
_position = 0;
}
await _writer.flush();
}