Flushable class abstract

An object that can be flushed.

The flush method is invoked to write any buffered output to the underlying stream or device. This is particularly important for buffered streams where data may be held in memory until the buffer is full or explicitly flushed.

Example Usage

class BufferedOutput implements Flushable {
  final List<int> _buffer = [];
  final OutputStream _output;
  
  BufferedOutput(this._output);
  
  void write(int byte) {
    _buffer.add(byte);
    if (_buffer.length >= 1024) {
      flush(); // Auto-flush when buffer is full
    }
  }
  
  @override
  Future<void> flush() async {
    if (_buffer.isNotEmpty) {
      await _output.write(_buffer);
      _buffer.clear();
    }
  }
}
Implementers

Constructors

Flushable()
An object that can be flushed.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

flush() Future<void>
Flushes this stream by writing any buffered output to the underlying stream.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited