AnimatedIcon按钮旋转动画

class addView extends StatefulWidget {
  @override
  _addViewViewState createState() => _addViewViewState();
}
// 1,with TickerProviderStateMixin 要继承这样类

class _addViewViewState extends State  with TickerProviderStateMixin{
//动画效果
  AnimationController animationController;

  @override
  void initState() {
    super.initState();
    animationController = AnimationController(
      vsync: this,
      duration: Duration(milliseconds: 1000),
    );
    animationController.forward(); //加上这个,动画才能执行,可以放到按钮的点击事件里面去,
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('新增页面'),
        elevation: 2.0,
      ),
      body: Center(
        child: AnimatedIcon(
            icon: AnimatedIcons.menu_arrow, progress: animationController),
      ),
    );
  }
}

你可能感兴趣的:(AnimatedIcon按钮旋转动画)