flutter一个简单的平移动画,简单动画

//定义属性
AnimationController animationController;
Animation movement;
void initMyController(){
    animationController = AnimationController(
      duration: Duration(milliseconds: 5000),
        vsync: this,
    );
  }
initAni(){
    movement = Tween(
      begin: EdgeInsets.only(left: 0),
      end: EdgeInsets.only(left: 100)
    ).animate(
      animationController
    )..addListener((){
      setState(() {

      });
    });
    animationController.forward();
  }
@override
  void dispose() {
    // TODO: implement dispose
   animationController?.dispose();
    super.dispose();
  }
Container(
            color: Colors.red,
            width: 300,
            height: 100,
            padding: movement.value,
            child: Text('这是一个移动动画测试'),
          )

 

你可能感兴趣的:(Flutter,flutter动画)