flutter一个简单的平移动画,简单动画
程序员文章站
2022-06-15 14:53:13
...
//定义属性 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('这是一个移动动画测试'),
)