class _MyHomePageState2 extends State with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this, duration: Duration(milliseconds: 3000));
_controller.addListener(() {
setState(() {});
});
_animation = TweenSequence([//这是一个动画序列,weight表示权重
TweenSequenceItem(tween: Tween(begin: 50.0,end: 100.0).chain(CurveTween(curve: Curves.easeOut)),weight: 50),
TweenSequenceItem(tween: Tween(begin: 100.0,end: 150.0).chain(CurveTween(curve: Curves.easeOut)),weight: 50)
]).animate(_controller);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Center(
child: InkWell(
onTap: () {
if (_controller.isDismissed) {
_controller.forward();
} else {
_controller.reverse();
}
},
child: Container(
width: _animation.value,
height: _animation.value,
decoration: BoxDecoration(
shape: BoxShape.circle, color: Colors.blue),
),
),
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
Flutter的Animation中TweenSequence的用法
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 1.关键字解析 extends:继承Class with:混入Class implements:实现Class这三...
- 在Flutter中,有如下三种关系: 继承(关键字 extends) 混入 mixins (关键字 with) 接...
- BoxDecoration 这个控件用的挺多的,能够更好的理解和使用,相信会很有帮助