flutter - 来回动画不能在颤动中工作
问题描述
我正在尝试使容器具有从绿色到黄色来回动画的颜色。我尝试了以下,但它的动画是从绿色到黄色而不是从黄色到绿色..
class MyAnimmmmmState extends State<MyAnimmmm> with TickerProviderStateMixin {
AnimationController animCtrl;
Animation<Color> colorAnimation;
@override
void initState() {
animCtrl = AnimationController(vsync: this, duration: Duration(seconds: 1))..repeat(reverse: true);
colorAnimation = ColorTween(begin: Colors.green, end: Colors.yellow).animate(animCtrl);
super.initState();
}
@override
Widget build(BuildContext context) {
return
AnimatedBuilder(
animation: animCtrl,
builder: (_, __) => Container(
width: 100,
height: 100,
decoration: ShapeDecoration(shape: StadiumBorder(), color: colorAnimation.value),
child: Center(child: Text('yooosters', style: TextStyle())))),
}
我怎样才能让它来回动画?
解决方案
推荐阅读
- reactjs - 使用 React 构建 REST 后端 API 调用的最佳方式是什么?
- vb.net-2010 - 在 datetimepicker 中使用什么事件
- sql-server-2017 - 将列添加到一个巨大的表
- docusignapi - Docusign 电子邮件地址未定义
- email - Drupal 8 自定义模块停止发送电子邮件按电子邮件地址过滤
- vue.js - Nuxt.js:结合过渡(到,从)和进入/离开事件
- ruby - 有人可以解释一下如何注入(Hash.new(0)) { |total, bigram| 总计 [bigram] += 1; 总计 }.sort_by { |_key, value| 值 }.reverse.to_h 有效吗?
- c# - 列表框中的按钮
- json - Golang中复杂结构的json编组
- animation - 如何在 Flutter 中动态缩放小部件(在我的情况下是卡片)?