progressBar method

void progressBar(
  1. double ratio, {
  2. int width = 20,
  3. String filledChar = '█',
  4. String emptyChar = '░',
  5. bool showPercent = true,
})

Writes a progress bar line: │ ████████░░░░ 75%

Implementation

void progressBar(
  double ratio, {
  int width = 20,
  String filledChar = '█',
  String emptyChar = '░',
  bool showPercent = true,
}) {
  final clamped = ratio.clamp(0.0, 1.0);
  final filled = (clamped * width).round();
  final bar =
      '${theme.accent}${filledChar * filled}${theme.reset}${theme.dim}${emptyChar * (width - filled)}${theme.reset}';
  if (showPercent) {
    final pct = (clamped * 100).round();
    gutterLine('$bar ${theme.dim}$pct%${theme.reset}');
  } else {
    gutterLine(bar);
  }
}