valueAt method
Word value for intervals not of pow2, e.g. 3 bytes, 5 bytes
Implementation
// allows non pow2 intervals. use case [2][3][3] stored in a int64
// truncates if size > lengthInBytes, i.e. lengthInBytes the comparable ByteData.getInt
// creates a new buffer
// does not sign extend
int valueAt(int byteOffset, int size, [Endian endian = Endian.little]) {
assert(size <= 8);
assert(byteOffset + size <= lengthInBytes, 'Read would exceed buffer bounds');
final endianOffset = switch (endian) {
Endian.big => 8 - size,
Endian.little => 0,
Endian() => throw StateError('Endian'),
};
return (Uint8List(8)..setAll(endianOffset, Uint8List.sublistView(this, byteOffset, byteOffset + size))).buffer.asByteData().getInt64(0, endian);
// or iterate bytemask on this
}