Writer class abstract interface

An interface for objects that are byte-oriented sinks.

Writers are defined by two required methods: write and flush:

  • write will attempt to write the provided bytes to the sink, returning how many bytes were actually written.
  • flush will ensure that all written data is actually written, useful for adapters and explicit buffers that may not write data immediately.

It is possible for operations to fail, such as writing to a closed socket or a full buffer. In these cases, the writer should document how it handles these errors, such as throwing an exception or returning a specific value.

Implementers

Constructors

Writer.fromSink(Sink<List<int>> sink, {Future<void> onFlush()?})
Creates a new writer that writes to the provided sink.
factory
Writer.fromStringSink(StringSink sink, {Encoding encoding, Future<void> onFlush()?})
Creates a new writer that writes to the provided string sink.
factory

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 the buffer, ensuring all written data is actually written.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
write(List<int> bytes, [int offset = 0, int? length]) int
Writes the provided bytes to the sink, optionally with offsets.

Operators

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