ScrollingSection constructor
ScrollingSection({
- required InlineTerminal terminal,
- int rows = 5,
- bool dim = true,
- String? heading,
- String? successMessage,
- String? failedMessage,
- bool captureOutput = false,
- Duration spinnerInterval = _defaultSpinnerInterval,
- Duration elapsed()?,
- 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();
}
}