-
Notifications
You must be signed in to change notification settings - Fork 1
/
loading2.dart
89 lines (82 loc) · 2.56 KB
/
loading2.dart
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/////////////////////////////////////////////////////////////
/// - Tushar Gupta ///
/////////////////////////////////////////////////////////////
import 'package:flutter/material.dart';
import 'package:flutter/animation.dart';
class loading2 extends StatefulWidget {
Color fromcolor;
Color tocolor;
loading2({Key key,@required this.fromcolor,@required this.tocolor}):super(key: key);
@override
_loading2State createState() => _loading2State();
}
class _loading2State extends State<loading2> with TickerProviderStateMixin{
AnimationController animationController;
AnimationController _controller;
Animation animation;
Animation animation1;
Tween tween;
Color fill1;
Color fill2;
createbubble(double begin, double end){
animation = tween.animate(CurvedAnimation(
parent: animationController,
curve: Interval(begin,end,curve: Curves.easeIn),
));
animation.addListener(() {setState(() {});});
animation.addStatusListener((status) {
if(status == AnimationStatus.completed){
animationController.reverse();
}else if(status == AnimationStatus.dismissed){
animationController.forward();
}
});
animation1 = ColorTween(begin: fill1,end: fill2).animate(_controller);
animation1.addListener(() {setState(() {});});
animation1.addStatusListener((status) {
if(status == AnimationStatus.completed){
_controller.reverse();
}else if(status == AnimationStatus.dismissed){
_controller.forward();
}
});
return Transform.scale(
scale: animation.value,
child: Row(
children: [
CircleAvatar(
backgroundColor: animation1.value,
radius: 8.0,
),
SizedBox(width: 5.0,)
],
),
);
}
@override
void initState() {
super.initState();
fill1 = widget.fromcolor;
fill2 = widget.tocolor;
animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 1500));
_controller = AnimationController(vsync: this, duration: Duration(milliseconds: 3000));
tween = Tween<double>(begin: 0.0,end: 1.0);
animationController.forward();
_controller.forward();
}
@override
Widget build(BuildContext context) {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
createbubble(0.0,0.2),
createbubble(0.2,0.4),
createbubble(0.4,0.6),
createbubble(0.6,0.8),
createbubble(0.8,1.0),
],
),
);
}
}