BinaryWriterCore extension

Core properties, operators, and lifecycle methods for BinaryWriter.

Provides access to the writer's state (bytesWritten, capacity), random-access operators ([], []=), byte extraction (takeBytes, toBytes), and reset functionality.

Example:

final writer = BinaryWriter();
writer.writeUint32(42);

print(writer.bytesWritten);  // 4
print(writer[0]);            // 0x2A

writer[0] = 0xFF;            // Overwrite first byte

final bytes = writer.takeBytes();  // Extract and reset
on

Properties

bytesWritten → int

Available on BinaryWriter, provided by the BinaryWriterCore extension

Returns the total number of bytes written to the buffer.
no setter
capacity → int

Available on BinaryWriter, provided by the BinaryWriterCore extension

Returns the current capacity of the internal buffer.
no setter

Methods

call(List<int> bytes) → void

Available on BinaryWriter, provided by the BinaryWriterCore extension

Writes a sequence of bytes.
reset() → void

Available on BinaryWriter, provided by the BinaryWriterCore extension

Resets the writer to its initial state, discarding all written data.
takeBytes({bool copy = false}) → Uint8List

Available on BinaryWriter, provided by the BinaryWriterCore extension

Extracts all written bytes and resets the writer.
toBytes() → Uint8List

Available on BinaryWriter, provided by the BinaryWriterCore extension

Returns a view of the written bytes (from index 0 up to the current bytesWritten) without resetting the writer.

Operators

operator [](int index) → int

Available on BinaryWriter, provided by the BinaryWriterCore extension

Returns the byte at the specified index without changing the current write position.
operator []=(int index, int value) → void

Available on BinaryWriter, provided by the BinaryWriterCore extension

Writes a byte at the specified index without changing the current write position.