I'm using the Linear Percent Indicator for a progress bar. Each time this percentage value changes, the animation goes from 0 to the current progress number. I want the animation to go from the last progress number to the current progress number.
without the animation, the bar makes a correct "jump" (from the last number to the current one), but the animation is needed.
Gif of how the problem is:
how it should be:
My code:
Consumer<ProgressBarProvider>(
builder: (BuildContext context, value, Widget? child) {
return LinearPercentBar:
Center(
child: LinearPercentIndicator(
animation: true,
progressColor: Theme.of(context).primaryColor,
backgroundColor: Color.fromRGBO(217, 217, 217, 1),
percent: value.getPercentProgress,
lineHeight: 15,
linearStrokeCap: LinearStrokeCap.roundAll,
barRadius: Radius.circular(30),
restartAnimation: false,
)
);
}
I'm using the Provider library to manage the state of the percentage and the number of items variables.
I want to know how do I leave the animation from one number to the next without the animation going all the way to the current number
I solve! I only needed add the parameter
animateFromLastPercent: true,
into LinearPercentIndicator. It was like this:
LinearPercentIndicator(
animation: true,
animationDuration: 500,
animateFromLastPercent: true,
progressColor: Theme.of(context).primaryColor,
backgroundColor: Color.fromRGBO(217, 217, 217, 1),
percent: value.getPercentProgress,
lineHeight: 15,
linearStrokeCap: LinearStrokeCap.roundAll,
barRadius: Radius.circular(30),
restartAnimation: false,
)