formatProgress method

String formatProgress(
  1. int current,
  2. int total, {
  3. String? label,
  4. int barWidth = 30,
})

Renders an ASCII progress bar.

Implementation

String formatProgress(
  int current,
  int total, {
  String? label,
  int barWidth = 30,
}) {
  final pct = total > 0 ? (current / total).clamp(0.0, 1.0) : 0.0;
  final filled = (pct * barWidth).round();
  final empty = barWidth - filled;
  final bar = '${'█' * filled}${'░' * empty}';
  final pctStr = '${(pct * 100).toStringAsFixed(0)}%';
  final prefix = label != null ? '$label ' : '';
  return '$prefix${theme.info}$bar${theme.reset} '
      '${theme.number}$pctStr${theme.reset} ($current/$total)';
}