BytesBuffer class

Optimized buffer of Uint8List.

Available Extensions

Constructors

BytesBuffer([int initialCapacity = 32])
BytesBuffer.from(Uint8List bytes, {int offset = 0, int? length, int? bufferLength, bool copyBuffer = false})
BytesBuffer.fromIO(BytesIO bytesIO)

Properties

bytesIO BytesIO
final
capacity int
Returns the size of the internal bytes buffer (Uint8List).
no setter
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
Returns true if bytesIO is closed.
no setter
isEmpty bool
Returns true if this instance is empty.
no setter
isNotEmpty bool
Returns true if this instance is NOT empty.
no setter
length int
The length of bytes in this buffer.
no setter
position int
The current read/write cursor position in the bytes buffer.
no setter
remaining int
The remaining bytes to read from position to the end of the buffer.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asUint8List([int offset = 0, int? length]) Uint8List
Returns this instance as a Uint8List. Returns the internal bytes buffer if the length and capacity is the same, otherwise creates a copy with the exact length.
bytesTo<R>(R output(Uint8List bytes, int offset, int length), [int offset = 0, int? length]) → R
Calls the function output with the internal bytes of this instance.
close() → void
Closes bytesIO.
compact() bool
Compact the internal bytes capacity to length.
flush() → void
Flushes bytesIO data.
indexOf(int byte, [int offset = 0, int? length]) int
Returns the index of byte inf offset and length range.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAllFloat32(int length) List<double>
Reads a List of 32-bit double values with a specified length.
readAllFloat64(int length) List<double>
Reads a List of 64-bit double values with a specified length.
readBigInt() BigInt
Reads a BigInt. See BigIntExtension.toBytes for encoding description.
readBlock16() Uint8List
Reads a blocks of data that uses a 16-bit integer as length prefix.
readBlock32() Uint8List
Reads a blocks of data that uses a 32-bit integer as length prefix.
readBlocks() List<Uint8List>
Reads a lists of bytes blocks. Uses readBlock32.
readBoolean() bool
Reads 1 boolean byte. Increments position by 1.
readByte() int
Reads 1 byte. Increments position by 1.
readBytes(int length) Uint8List
Reads an Uint8List of length.
readDateTime() DateTime
Reads a DateTime.
readEnum<E extends Enum>(List<E> enumValues) → E
Reads an enum index, and returns a value from enumValues. Increments position by 1.
readFloat32() double
Reads a double 32 bits.
readFloat64() double
Reads a double 64 bits.
readInt16([Endian endian = Endian.big]) int
Reads an Int16.
readInt32([Endian endian = Endian.big]) int
Reads an Int32.
readInt64([Endian endian = Endian.big]) int
Reads an Int64.
readRemainingBytes() Uint8List
Reads the remaining bytes. See remaining and readBytes.
readString() String
Reads a String using UTF-8 decoding.
readTo(BytesBuffer dst, [int? length]) int
Reads length bytes into dst.
readUint16([Endian endian = Endian.big]) int
Reads an Uint16.
readUint32([Endian endian = Endian.big]) int
Reads an Uint32.
readUint64([Endian endian = Endian.big]) int
Reads an Uint64.
readWritable<W extends Writable>(W reader(BytesBuffer input)) → W
Reads a Writable using the reader function to instantiate the W instance.
readWritables<W extends Writable>(W reader(BytesBuffer input), {bool leb128 = false}) List<W>
Reads a list of Writable using the reader function to instantiate the W elements.
reset() → void
Resets this buffer. Sets the length and position to 0.
seek(int position) int
Changes the read/write cursor position.
setLength(int length) → void
Sets the length of this buffer. Increases internal bytes buffer capacity if needed.
toBytes([int offset = 0, int? length]) Uint8List
Returns a copy of the internal bytes (Uint8List) of this instance.
toString() String
A string representation of this object.
override
write(List<int> list, [int offset = 0, int? length]) int
Writes the int at list as bytes, respecting offset and length parameters.
writeAll(List<int> list) int
Writes all the int at list as bytes.
writeAllBytes(Uint8List bytes) int
Writes all the bytes into this buffer.
writeAllFloat32(List<double> ns) int
Writes all ns as double 32 bits.
writeAllFloat64(List<double> ns) int
Writes all ns as double 64 bits.
writeBigInt(BigInt n) int
Writes a BigInt. See BigIntExtension.toBytes for encoding description.
writeBlock16(Uint8List bs, [int offset = 0, int? length]) int
Writes a blocks of data using a 16-bit integer as length prefix.
writeBlock32(Uint8List bs, [int offset = 0, int? length]) int
Writes a blocks of data using a 32-bit integer as length prefix.
writeBlocks(Iterable<Uint8List> blocks) int
Writes a lists of bytes blocks. Uses writeBlock32.
writeBoolean(bool b) int
Writes 1 boolean byte. Increments position by 1.
writeByte(int b) int
Writes 1 byte. Increments position by 1.
writeBytes(Uint8List bs, [int offset = 0, int? length]) int
Writes the bytes into this buffer, respecting offset and length parameters.
writeDateTime(DateTime dateTime) int
Writes a DateTime.
writeEnum<E extends Enum>(E e) int
Writes an enum e index. Increments position by 1.
writeFloat32(double n) int
Writes a double 32 bits.
writeFloat64(double n) int
Writes a double 64 bits.
writeFrom(BytesBuffer src, [int? length]) int
Writes length bytes from src.
writeInt16(int n, [Endian endian = Endian.big]) int
Writes an Int16.
writeInt32(int n, [Endian endian = Endian.big]) int
Writes an Int32.
writeInt64(int n, [Endian endian = Endian.big]) int
Writes an Int64.
writeString(String s) int
Writes a String using UTF-8 encoding.
writeUint16(int n, [Endian endian = Endian.big]) int
Writes an Uint16.
writeUint32(int n, [Endian endian = Endian.big]) int
Writes an Uint32.
writeUint64(int n, [Endian endian = Endian.big]) int
Writes an Uint64.
writeWritable(Writable writable) int
Writes a writable. See Writable.
writeWritables(Iterable<Writable> list, {bool leb128 = false}) int
Writes a list of Writable.

Operators

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