matthewfx / sleek_circular_slider

Sleek circular slider for Flutter
MIT License
524 stars 102 forks source link

Add track gradient #17

Closed cirediew closed 4 years ago

cirediew commented 4 years ago

It would be great if you could add a gradient for the track! Either use the progressBarColors when trackColor is null. Or something like this in _CurvePainter by adding trackColors:

  final progressBarRect = Rect.fromLTWH(0.0, 0.0, size.width, size.width);

  Paint trackPaint;
  if (appearance.trackColors != null){
    final trackGradient = SweepGradient(
      startAngle: degreeToRadians(appearance.gradientStartAngle),
      endAngle: degreeToRadians(appearance.gradientStopAngle),
      tileMode: TileMode.mirror,
      colors: appearance.trackColors,
    );
    trackPaint = Paint()
      ..shader = trackGradient.createShader(progressBarRect)
      ..strokeCap = StrokeCap.round
      ..style = PaintingStyle.stroke
      ..strokeWidth = appearance.trackWidth;
  } else {
    trackPaint = Paint()
      ..strokeCap = StrokeCap.round
      ..style = PaintingStyle.stroke
      ..strokeWidth = appearance.trackWidth
      ..color = appearance.trackColor;
  }
  drawCircularArc(
      canvas: canvas,
      size: size,
      paint: trackPaint,
      ignoreAngle: true,
      spinnerMode: appearance.spinnerMode);
matthewfx commented 4 years ago

I will try when I find the time. :)

matthewfx commented 4 years ago

It has been added in v. 1.2