appendLine method

void appendLine(
  1. String line
)

Appends line to the section and re-renders.

If line itself contains newlines it is split so each part occupies a single visual row. Once more than rows lines have been appended, the oldest lines scroll out of view.

Implementation

void appendLine(final String line) {
  if (_finished) {
    throw StateError('Cannot append to a finished ScrollingSection.');
  }

  if (!_started) {
    _started = true;
    _renderer.hideCursor();
  }

  for (final part in line.split('\n')) {
    _visibleLines.addLast(part);
    while (_visibleLines.length > rows) {
      _visibleLines.removeFirst();
    }
    if (captureOutput) _captured.add(part);
  }

  _render();
}