In Dart/Flutter, I'm trying to read bytes from a data file (2 bytes per value; on a mobile device) and convert to a double.
I have the below code:
fileToData(File filename) {
var bytes = filename.readAsBytesSync();
return bytes.buffer.asInt16List().map((e) {
print("Value: ${e.toDouble()}");
return e.toDouble();
}).toList();
}
The return List values are all 0.0; however, in the print statement I see the e.toDouble()
is not 0.0 and is indeed the correct value expected. I just can't seem to return it.
For example:
I/flutter (10636): Value: 404.0
I/flutter (10636): Value: 356.0
I/flutter (10636): Value: 345.0
I/flutter (10636): Value: 297.0
I/flutter (10636): Value: 200.0
I/flutter (10636): Value: 164.0
Back the returned List<double>
is:
I/flutter (10636): SIGNAL: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,.....
Any suggestions? Thanks.