ByteArray class

The ByteArray class provides methods and properties to optimize reading, writing, and working with binary data.

Constructors

ByteArray([List<int>? buffer])

Properties

bytes List<int>
no setter
bytesAvailable int
The number of bytes of data available for reading from the current position in the byte array to the end of the array.
no setter
endian Endian
Changes or reads the byte order for the data; either Endian.BIG_ENDIAN or Endian.LITTLE_ENDIAN.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
length int
The length of the ByteArray object, in bytes.
getter/setter pair
position int
Moves, or returns the current position, in bytes, of the file pointer into the ByteArray object.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clears the contents of the byte array and resets the length and position properties to 0.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readBoolean() bool
Reads a Boolean value from the byte stream.
readByte() int
Reads a signed byte from the byte stream.
readBytes(ByteArray bytes, [int offset = 0, int length = 0]) → void
Reads the number of data bytes, specified by the length parameter, from the byte stream.
readDouble() double
Reads an IEEE 754 double-precision (64-bit) floating-point number from the byte stream.
readFloat() double
Reads an IEEE 754 single-precision (32-bit) floating-point number from the byte stream.
readInt() int
Reads a signed 32-bit integer from the byte stream.
readInt64() int
Reads a signed 64-bit integer from the byte stream.
readShort() int
Reads a signed 16-bit integer from the byte stream.
readUnsignedByte() int
Reads an unsigned byte from the byte stream.
readUnsignedInt() int
Reads an unsigned 32-bit integer from the byte stream.
readUnsignedInt64() int
Reads an unsigned 64-bit integer from the byte stream.
readUnsignedShort() int
Reads an unsigned 16-bit integer from the byte stream.
readUTF() String
Reads a UTF-8 string from the byte stream. The string is assumed to be prefixed with an unsigned short indicating the length in bytes.
readUTFBytes(int length) String
Reads a sequence of UTF-8 bytes specified by the length parameter from the byte stream and returns a string.
toString() String
A string representation of this object.
override
writeBoolean(bool value) → void
Writes a Boolean value.
writeByte(int value) → void
Writes a byte to the byte stream.
writeBytes(ByteArray bytes, [int offset = 0, int length = 0]) → void
Writes a sequence of length bytes from the specified byte array, bytes, starting offset(zero-based index) bytes into the byte stream.
writeDouble(double value) → void
Writes an IEEE 754 double-precision (64-bit) floating-point number to the byte stream.
writeFloat(double value) → void
Writes an IEEE 754 single-precision (32-bit) floating-point number to the byte stream.
writeInt(int value) → void
Writes a 32-bit signed integer to the byte stream.
writeInt64(int value) → void
Writes a 64-bit signed integer to the byte stream.
writeShort(int value) → void
Writes a 16-bit integer to the byte stream.
writeUnsignedInt(int value) → void
Writes a 32-bit unsigned integer to the byte stream.
writeUnsignedInt64(int value) → void
Writes a 64-bit unsigned integer to the byte stream.
writeUTF(String value) → void
Writes a UTF-8 string to the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string.
writeUTFBytes(String value) → void
Writes a UTF-8 string to the byte stream. Similar to the writeUTF() method, but writeUTFBytes() does not prefix the string with a 16-bit length word.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](int i) → dynamic
operator []=(int i, int value) → void