我有星星png图像,我需要使用Flutter AnimationController和Transformer旋转星星。我找不到图像旋转动画的任何文档或示例。

任何想法如何使用Flutter AnimationController和Transform旋转图像?

更新:

class _MyHomePageState extends State with TickerProviderStateMixin {

AnimationController animationController;

@override

void initState() {

super.initState();

animationController = new AnimationController(

vsync: this,

duration: new Duration(milliseconds: 5000),

);

animationController.forward();

animationController.addListener(() {

setState(() {

if (animationController.status == AnimationStatus.completed) {

animationController.repeat();

}

});

});

}

@override

Widget build(BuildContext context) {

return new Container(

alignment: Alignment.center,

color: Colors.white,

child: new AnimatedBuilder(

animation: animationController,

child: new Container(

height: 80.0,

width: 80.0,

child: new Image.asset('images/StarLogo.png'),

),

builder: (BuildContext context, Widget _widget) {

return new Transform.rotate(

angle: animationController.value,

child: _widget,

);

},

),

);

}

}

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐