A fixed-length, random-access sequence of bytes that also provides random and unaligned access to the fixed-width integers and floating point numbers represented by those bytes.
ByteData
may be used to pack and unpack data from external sources
(such as networks or files systems), and to process large quantities
of numerical data more efficiently than would be possible
with ordinary List implementations.
ByteData
can save space, by eliminating the need for object headers,
and time, by eliminating the need for data copies.
Finally, ByteData
may be used to intentionally reinterpret the bytes
representing one arithmetic type as another.
For example this code fragment determine what 32-bit signed integer
is represented by the bytes of a 32-bit floating point number:
var buffer = new Uint8List(8).buffer;
var bdata = new ByteData.view(buffer);
bdata.setFloat32(0, 3.04);
int huh = bdata.getInt32(0);