finish method
Finishes the section.
success selects the completion icon (✓ or ✗) and which of
successMessage / failedMessage replaces the heading (when non-null).
Body retention is successRetention or failureRetention unless
overrideRetention is passed:
- RetainSection.keepCurrent leaves the visible lines in place
- RetainSection.keepFull re-displays the complete captured output (when captureOutput was enabled)
- RetainSection.clear removes the scrolling lines; the heading is kept when one is present, otherwise the region is cleared entirely
Implementation
void finish({required bool success, RetainSection? overrideRetention}) {
if (_finished) return;
_finished = true;
_success = success;
_stopSpinner();
_finishMessage = success ? successMessage : failedMessage;
final retention =
overrideRetention ?? (success ? successRetention : failureRetention);
switch (retention) {
case RetainSection.clear:
final header = _buildHeaderLine(_terminal.columns);
if (header != null) {
_renderer.finish(lines: [header]);
} else {
_renderer.clear();
}
case RetainSection.keepCurrent:
_renderer.finish(lines: _buildLines());
case RetainSection.keepFull:
_renderer.finish(lines: _buildLines(full: true));
}
}