Reputation: 8953
I am reading a binary file and want to transform it into a String. How do I do it in Dart?
Upvotes: 11
Views: 7398
Reputation: 9545
Try the following
String getStringFromBytes(ByteData data) {
final buffer = data.buffer;
var list = buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
return utf8.decode(list);
}
Also see this answer.
Upvotes: 6