ScrollingSection constructor

ScrollingSection({
  1. required InlineTerminal terminal,
  2. int rows = 5,
  3. bool dim = true,
  4. String? heading,
  5. String? successMessage,
  6. String? failedMessage,
  7. bool captureOutput = false,
  8. Duration spinnerInterval = _defaultSpinnerInterval,
  9. Duration elapsed()?,
  10. SpinnerScheduler? scheduleTicker,
})

Creates a scrolling section rendered to terminal.

rows is the fixed number of visual rows (must be at least 1, default 5).

spinnerInterval controls how often the spinner advances. elapsed and scheduleTicker are injection points for tests so the animation and elapsed time can be driven deterministically; production code should leave them unset.

Implementation

ScrollingSection({
  required final InlineTerminal terminal,
  this.rows = 5,
  this.dim = true,
  this.heading,
  this.successMessage,
  this.failedMessage,
  this.captureOutput = false,
  final Duration spinnerInterval = _defaultSpinnerInterval,
  final Duration Function()? elapsed,
  final SpinnerScheduler? scheduleTicker,
}) : assert(rows >= 1, 'rows must be at least 1'),
     _terminal = terminal,
     _renderer = BottomRegionRenderer(terminal),
     _spinnerInterval = spinnerInterval,
     _elapsedOverride = elapsed,
     _scheduleTicker = scheduleTicker ?? _defaultScheduler {
  // Show the heading immediately, even before any output arrives, and start
  // the spinner/elapsed animation alongside it.
  if (heading != null) {
    _started = true;
    _renderer.hideCursor();
    _spinnerActive = _terminal.hasTerminal;
    if (_spinnerActive) {
      _stopwatch.start();
      _cancelTicker = _scheduleTicker(_spinnerInterval, _tick);
    }
    _render();
  }
}