Reputation: 13
I am converting Java code to Dart, but I am stuck in Little Endian oder, Any ideas to help me?
Java:
void displayString(byte[] record) {
ByteBuffer bb = ByteBuffer.wrap(record);
bb.order(ByteOrder.LITTLE_ENDIAN);
.....
}
Dart:
_displayString(List<int> record) {
var _list = Uint8List.fromList(record);
// HOW TO ORDER LITTLE ENDIAN Like Java
.....
}
Upvotes: 1
Views: 1894
Reputation: 51751
The closest equivalent to Java Byte buffer is Dart's ByteData.
var byteData = _list.buffer.asByteData();
You can't set its order globally, but you can specify it for each get or set.
byteData.setFloat32(0, 3.04, Endian.little);
Upvotes: 1