LinearPainter constructor

LinearPainter({
  1. required double lineWidth,
  2. required double progress,
  3. required bool isRTL,
  4. required Color progressColor,
  5. required Color backgroundColor,
  6. LinearStrokeCap? linearStrokeCap = LinearStrokeCap.butt,
  7. LinearGradient? linearGradient,
  8. MaskFilter? maskFilter,
  9. required bool clipLinearGradient,
  10. LinearGradient? linearGradientBackgroundColor,
})

Implementation

LinearPainter({
  required this.lineWidth,
  required this.progress,
  required this.isRTL,
  required this.progressColor,
  required this.backgroundColor,
  this.linearStrokeCap = LinearStrokeCap.butt,
  this.linearGradient,
  this.maskFilter,
  required this.clipLinearGradient,
  this.linearGradientBackgroundColor,
}) {
  _paintBackground.color = backgroundColor;
  _paintBackground.style = PaintingStyle.stroke;
  _paintBackground.strokeWidth = lineWidth;

  _paintLine.color = progress.toString() == "0.0"
      ? progressColor.withOpacity(0.0)
      : progressColor;
  _paintLine.style = PaintingStyle.stroke;
  _paintLine.strokeWidth = lineWidth;

  if (linearStrokeCap == LinearStrokeCap.round) {
    _paintLine.strokeCap = StrokeCap.round;
  } else if (linearStrokeCap == LinearStrokeCap.butt) {
    _paintLine.strokeCap = StrokeCap.butt;
  } else {
    _paintLine.strokeCap = StrokeCap.round;
    _paintBackground.strokeCap = StrokeCap.round;
  }
}