print method

void print(
  1. String text
)

Appends a string indented to the current level. (Indentation will be added after newline characters where needed.)

Implementation

void print(String text) {
  _previousOffset = _buffer.length;
  final lastNewline = text.lastIndexOf('\n');
  if (lastNewline == -1) {
    _writeChunk(text);
    return;
  }

  for (final line in text.substring(0, lastNewline).split('\n')) {
    _writeChunk(line);
    _newline();
  }
  _writeChunk(text.substring(lastNewline + 1));
}