toString method

  1. @override
String toString()
override

The string in use, decoded. An all-ASCII payload skips the UTF-8 decoder.

Implementation

@override
String toString() {
  final s = storage;
  final n = length;
  var i = 0;
  while (i < n && s[i] < 0x80) {
    i++;
  }
  if (i == n) return String.fromCharCodes(s, 0, n);
  return utf8.decoder.convert(s, 0, n);
}