Flutter AlwaysStoppedAnimation() is great for animation which is used inside CircularProgressIndicator(). Without AlwaysStoppedAnimation(), CircularProgressIndicator runs very fast and we fast moving circle.
We may use this to animate color.
SizedBox(
height: 220,
width: 220,
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
stats['isPrelude']
? Colors.red
: Colors.blue),
strokeWidth: 25,
value: stats['exerciseProgress']))
We can do color animation with this. Based on different condition we show different animation color inside AlwaysStoppedAnimation() widget.
In our case, we have used BLoC state management to change the stats[‘exerciseProgress’] value and update it.
Since stats[‘exerciseProgress’] gets updated regularly, we see a CircularProgressIndicator with animation.
stats[‘exerciseProgress’] value must change from 0.0 to 1.0 over the time. As the value changes, we see the animation.