9

I am reading a binary file and want to transform it into a String. How do I do it in Dart?

Oswin Noetzelmann
  • 9,166
  • 1
  • 33
  • 46
Daniel Oliveira
  • 8,053
  • 11
  • 40
  • 76

1 Answers1

5

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.

Oswin Noetzelmann
  • 9,166
  • 1
  • 33
  • 46