progressBar method

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

Creates an inline progress bar: ████░░░░ 75%

Implementation

String progressBar(
  double ratio, {
  int width = 10,
  bool showPercent = true,
  String filledChar = '█',
  String emptyChar = '░',
}) {
  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();
    return '$bar ${dim('$pct%')}';
  }
  return bar;
}