fromBytesAsFloat function
Convert a list of bytes to floating point value.
The length of bytes has to be 4 or 8, otherwise a MemException
gets thrown.
If bytes is 4 bytes long it's treated as Float32,
otherwise it's Float64.
Implementation
double fromBytesAsFloat(Uint8List bytes) {
int byteCnt = bytes.length;
switch (byteCnt) {
case 4:
return bytes.buffer.asFloat32List(1)[0];
case 8:
return bytes.buffer.asFloat64List(1)[0];
default:
throw MemException("Invalid byte list length: $byteCnt");
}
}