FillingBar constructor

FillingBar({
  1. required int total,
  2. String desc = "",
  3. String space = ".",
  4. String fill = "█",
  5. bool time = false,
  6. bool percentage = false,
  7. double scale = 0.5,
  8. int? width,
})

Arguments:

  • total : Total number of steps
  • desc : Simple text shown before the bar (optional)
  • space : Character denoting empty space (default : '.')
  • fill : Character denoting filled space (default : '█')
  • time : Toggle timing mode (default : false)
  • percentage : Toggle percentage display (default : false)
  • scale : Scale of the bar relative to width (between: 0 and 1, default: 0.5, Irrelavant if width is specified)
  • width : Width of the bar (If not specified, it will be automatically calculated using the terminal width and scale)

Implementation

FillingBar(
    {required int total,
    String desc = "",
    this.space = ".",
    this.fill = "█",
    this.time = false,
    this.percentage = false,
    this.scale = 0.5,
    this.width})
    : _desc = desc,
      _total = total {
  // Handles width of the bar, throws an error if it's not specified and the terminal width is not available
  try {
    max = width ?? ((stdout.terminalColumns - _desc.length) * scale).toInt();
  } on StdoutException {
    throw StdoutException(
        "Could not get terminal width, try specifying a width manually");
  }
  if (time) {
    _clock.start();
    scheduleMicrotask(autoRender);
  }
  _render();
}