Flutter动画

Posted by アライさん on 2019年10月22日
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
class _pageState extends State<Page> with SingleTickerProviderStateMixin {
Animation _doubleTween;
Animation _colorTween;
AnimationController _controller;

@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 1000), vsync: this);
_doubleTween = Tween<double>(begin: 100.0, end: 200.0).animate(_controller);
_colorTween = ColorTween(begin: Colors.white, end: Colors.grey)
.animate(_controller);
_controller.addListener(() {
setState(() {});
});
_controller.repeat(reverse: true);
}

@override
Widget build(BuildContext context) {
return Container(
height:100,
width: _doubleTween.value,
color:_colorTween.value,
);
}
}