@@ -107,6 +107,10 @@ class CircularPercentIndicator extends StatefulWidget {
107107 /// Set to true if you want to rotate linear gradient in accordance to the [startAngle] .
108108 final bool rotateLinearGradient;
109109
110+ /// Set true if you want to display only part of [linearGradient] based on percent value.
111+ /// Works only if [rotateLinearGradient] is true.
112+ final bool clipRotatedLinearGradient;
113+
110114 /// Return current percent value if animation is true.
111115 final Function (double value)? onPercentValue;
112116
@@ -140,6 +144,7 @@ class CircularPercentIndicator extends StatefulWidget {
140144 this .onAnimationEnd,
141145 this .widgetIndicator,
142146 this .rotateLinearGradient = false ,
147+ this .clipRotatedLinearGradient = false ,
143148 this .progressBorderColor,
144149 this .onPercentValue,
145150 }) : super (key: key) {
@@ -280,6 +285,7 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
280285 linearGradient: widget.linearGradient,
281286 maskFilter: widget.maskFilter,
282287 rotateLinearGradient: widget.rotateLinearGradient,
288+ clipRotatedLinearGradient: widget.clipRotatedLinearGradient,
283289 ),
284290 child: (widget.center != null )
285291 ? Center (child: widget.center)
@@ -396,6 +402,7 @@ class _CirclePainter extends CustomPainter {
396402 final bool reverse;
397403 final MaskFilter ? maskFilter;
398404 final bool rotateLinearGradient;
405+ final bool clipRotatedLinearGradient;
399406
400407 _CirclePainter ({
401408 required this .lineWidth,
@@ -413,6 +420,7 @@ class _CirclePainter extends CustomPainter {
413420 this .arcType,
414421 this .maskFilter,
415422 required this .rotateLinearGradient,
423+ required this .clipRotatedLinearGradient,
416424 }) {
417425 _paintBackground.color = backgroundColor;
418426 _paintBackground.style = PaintingStyle .stroke;
@@ -469,7 +477,9 @@ class _CirclePainter extends CustomPainter {
469477 radians (- 90 - progress + startAngle) - correction)
470478 : GradientRotation (radians (- 90.0 + startAngle) - correction),
471479 startAngle: radians (0 ).toDouble (),
472- endAngle: radians (progress).toDouble (),
480+ endAngle: clipRotatedLinearGradient
481+ ? radians (360 ).toDouble ()
482+ : radians (progress).toDouble (),
473483 tileMode: TileMode .clamp,
474484 colors: reverse
475485 ? linearGradient! .colors.reversed.toList ()
0 commit comments