首页 > 解决方案 > 如何在颤动中使用带有onSwipe事件的轮子旋转动画?

问题描述

我有一个轮子的图像,并尝试使用 onSwipe 事件在其上添加旋转动画。实际上我做了什么..我使用了 AnimatedBuider 类,但图像最初正在旋转。

这里的图像

AnimatedBuilder(
  animation: animationController,
  child: Container(
    alignment: Alignment.center,
    decoration: BoxDecoration(
      image: DecorationImage(
        image: AssetImage("assets/wheel.png", ),
        fit: BoxFit.contain,
      ),
      borderRadius: BorderRadius.all(Radius.circular(210.0)),
    ), 
    height: MediaQuery.of(context).size.height/2.3,
    width: MediaQuery.of(context).size.width/1,
  ),
  builder: (BuildContext context, Widget _widget) {
      return new Transform.rotate(
        angle: animationController.value * 6.3,
        child: _widget,
      );
    },
  ),

动画控制器

@override
void initState() {
  super.initState();
  animationController = new AnimationController(
    vsync: this,
    duration: new Duration(seconds: 7),
  );
  animationController.repeat();
}

标签: animationflutterdart

解决方案



推荐阅读