text property

Future<String> text

Returns the full UTF-8 text produced by this, with trailing newlines removed.

Implementation

Future<String> get text async {
  var text = const Utf8Decoder(allowMalformed: true)
      .convert(await collectBytes(this));

  var i = text.length - 1;
  while (i >= 0 && text.codeUnitAt(i) == $lf) {
    i--;
    if (i >= 0 && text.codeUnitAt(i) == $cr) i--;
  }

  return text.substring(0, i + 1);
}