1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| AnimationController _animationController; Animation _animation; @override void initState() { super.initState();
_animationController=AnimationController(vsync: this,duration: Duration(seconds: 5)); _animation=TweenSequence([ TweenSequenceItem(tween: Tween(begin: 100.0,end: 200.0).chain(CurveTween(curve: Curves.ease)), weight: 2), TweenSequenceItem(tween: ConstantTween(400.0), weight: 1), TweenSequenceItem(tween: Tween(begin: 200.0,end: 300.0), weight: 2) ]).animate(_animationController);
} Center( child: GestureDetector( onTap: () {_animationController.forward();}, child: Container( height: _animation.value, width: _animation.value, color: Colors.red, alignment: Alignment.center, child: Text('点我开始动画',), ), ), )
|