toDartString method

String toDartString({
  1. bool zeroTerminated = false,
})

Converts this UTF8 encoded byte array to a dart String.

Uses utf8 for the decoding. By default, the whole byte array is decoded and returned as string. If zeroTerminated is set to true, the decoder stops at the first 0 byte and only that part of the byte array is returned as a string.

Implementation

String toDartString({bool zeroTerminated = false}) {
  if (zeroTerminated) {
    return utf8.decode(takeWhile((value) => value != 0).toList());
  } else {
    return utf8.decode(this);
  }
}