RawWriter class
Writes values into a mutable byte buffer.
The buffer automatically expands if isExpanding is true. This class provides various helper methods to write primitive values, UTF-8 strings, and custom SelfEncoder objects.
Constructors
- RawWriter.withByteData(ByteData _byteData, {bool isExpanding = true})
- Creates a writer with a custom ByteData buffer.
- RawWriter.withCapacity(int capacity, {bool isExpanding = true})
-
Creates a writer with an allocated buffer of
capacitybytes.factory - RawWriter.withUint8List(Uint8List list, {bool isExpanding = true})
- Creates a writer backed by a Uint8List.
Properties
- bufferAsByteData → ByteData
-
Returns the internal ByteData buffer.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isExpanding → bool
-
Whether the buffer automatically expands when full.
final
- length ↔ int
-
Current written length (number of valid bytes).
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
ensureAvailableLength(
int length) → void -
Ensures the buffer has space for at least
lengthmore bytes. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toByteDataCopy(
) → ByteData - Returns a copy of the written bytes as ByteData.
-
toByteDataView(
) → ByteData - Returns a view of the written bytes as ByteData.
-
toString(
) → String -
A string representation of this object.
inherited
-
toUint8ListCopy(
) → Uint8List - Returns a copy of the written bytes as Uint8List.
-
toUint8ListView(
) → Uint8List - Returns a view of the written bytes as Uint8List.
-
writeByteData(
ByteData value, [int index = 0, int? writtenLength]) → void - Writes bytes from ByteData.
-
writeBytes(
List< int> value, [int index = 0, int? writtenLength]) → void - Writes bytes from a List<int>.
-
writeFixInt64(
Int64 value, [Endian endian = Endian.big]) → void -
Writes a 64-bit integer (
Int64). -
writeFloat32(
double value, [Endian endian = Endian.big]) → void - Writes a 32-bit floating-point value.
-
writeFloat64(
double value, [Endian endian = Endian.big]) → void - Writes a 64-bit floating-point value.
-
writeInt16(
int value, [Endian endian = Endian.big]) → void - Writes a 16-bit signed integer.
-
writeInt32(
int value, [Endian endian = Endian.big]) → void - Writes a 32-bit signed integer.
-
writeInt8(
int value) → void - Writes an 8-bit signed integer.
-
writeSelfEncoder(
SelfEncoder encoder) → void - Writes a SelfEncoder object.
-
writeUint16(
int value, [Endian endian = Endian.big]) → void - Writes a 16-bit unsigned integer.
-
writeUint32(
int value, [Endian endian = Endian.big]) → void - Writes a 32-bit unsigned integer.
-
writeUint8(
int value) → void - Writes an 8-bit unsigned integer.
-
writeUtf8(
String value, {int? maxLengthInBytes}) → int - Writes a UTF-8 string. Returns the number of bytes written.
-
writeUtf8NullEnding(
String value, {int? maxLengthInBytes}) → int - Writes a UTF-8 string with a trailing null byte.
-
writeUtf8Simple(
String value) → void - Writes a single-byte UTF-8 string.
-
writeUtf8SimpleNullEnding(
String value) → void - Writes a null-terminated single-byte UTF-8 string.
-
writeVarInt(
int value) → void - Writes a variable-length signed integer.
-
writeVarUint(
int value) → void - Writes a variable-length unsigned integer.
-
writeZeroes(
int writtenLength) → void -
Writes
writtenLengthzero bytes.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited