drawBar method

void drawBar(
  1. Canvas canvas,
  2. Size size
)

Implementation

void drawBar(Canvas canvas, Size size) {
  Paint paint = Paint()
    ..color = barColor
    ..style = PaintingStyle.fill
    ..strokeCap = StrokeCap.round;

  double left = 0;
  double top = 0;
  double right = size.width / 100 * percent;
  double bottom = size.height;

  //the bar width needs to be bigger than radius width
  if (barRadius != 0 && right > 0 && barRadius * 2 > right) {
    right = barRadius * 2;
  }

  canvas.drawRRect(
      RRect.fromRectAndRadius(
        Rect.fromLTRB(left, top, right, bottom),
        Radius.circular(barRadius),
      ),
      paint);
}