如何创建一个动态确定圆形进度指示器?

17

如何在Flutter中创建类似这样的东西:

enter image description here

我尝试了下面的代码,但是它没有动画效果。

CircularProgressIndicator(
  value: 0.50,
  backgroundColor: Colors.grey,
  valueColor: AlwaysStoppedAnimation(Colors.pink),
)

1
为了使其动画化,您必须随着时间的推移定期更改该值,它可以从0开始,每100毫秒增加0.1,直到达到0.5。 - Ayman Barghout
1个回答

30
你可以使用一个ImplicityAnimatedWidget,例如 TweenAnimationBuilder
示例:
这将在3.5秒内进行动画处理,并且进度将从0%到100%,你可以在begin:end:参数中进行微调。
TweenAnimationBuilder<double>(
    tween: Tween<double>(begin: 0.0, end: 1),
    duration: const Duration(milliseconds: 3500),
    builder: (context, value, _) => CircularProgressIndicator(value: value),
)

你还可以使用AnimatedBuilder来更好地控制动画。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接