Skip to content

Commit 8dd3671

Browse files
committed
Update main.dart
1 parent ec5f35d commit 8dd3671

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

example/lib/main.dart

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,48 +28,94 @@ class MyApp extends StatelessWidget {
2828
}
2929

3030
class AnimatedCell extends StatelessWidget {
31+
AnimatedCell({this.configMap,this.text,this.autoPlay = false,this.curve});
32+
final Map<double,AnimatedConfig> configMap;
33+
final String text;
34+
final bool autoPlay;
35+
final Curve curve;
3136
@override
3237
Widget build(BuildContext context) {
3338
GlobalKey<SmartAnimatedWidgetState> key = GlobalKey<SmartAnimatedWidgetState>();
3439

3540
return GestureDetector(
3641
onTap: () {
3742
key.currentState.animate();
38-
print("**************tap*************");
3943
},
4044
child: SmartAnimatedWidget(
41-
configMap: slideOutDown,
45+
configMap: configMap,
4246
key: key,
43-
autoPlay: false,
47+
autoPlay: autoPlay,
48+
curve: curve,
49+
onTransitionEnd: (){
50+
Future.delayed(Duration(milliseconds: 200),(){
51+
if(autoPlay == false)key.currentState.reset();
52+
});
53+
},
4454
child: Container(
4555
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 15),
4656
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 15),
4757
width: double.infinity,
4858
color: Colors.red.shade300,
4959
child: Center(
50-
child: Text("BounceIn"),
60+
child: Text(text),
5161
),
5262
)),
5363
);
5464
}
5565
}
5666

67+
List<AnimatedCell> cells= [
68+
AnimatedCell(configMap: fadeInDown,text: "fadeInDown",autoPlay: true,),
69+
AnimatedCell(configMap: fadeInUp,text: "fadeInUp",autoPlay: true,),
70+
AnimatedCell(configMap: fadeInLeft,text: "fadeInLeft",autoPlay: true,),
71+
AnimatedCell(configMap: fadeInRight,text: "fadeInRight",autoPlay: true,),
72+
AnimatedCell(configMap: bounceIn,text: "bounceIn",autoPlay: true,),
73+
AnimatedCell(configMap: bounceInUp,text: "bounceInUp",autoPlay: true,),
74+
AnimatedCell(configMap: bounceInDown,text: "bounceInDown",autoPlay: true,),
75+
AnimatedCell(configMap: bounceInLeft,text: "bounceInLeft",autoPlay: true,),
76+
AnimatedCell(configMap: bounceInRight,text: "bounceInRight",autoPlay: true,),
77+
AnimatedCell(configMap: bounceOut,text: "bounceout"),
78+
AnimatedCell(configMap: bounceOutDown,text: "bounceOutDown"),
79+
AnimatedCell(configMap: bounceOutUp,text: "bounceOutUp"),
80+
AnimatedCell(configMap: bounceOutLeft,text: "bounceOutLeft"),
81+
AnimatedCell(configMap: bounceOutRight,text: "bounceOutRight"),
82+
AnimatedCell(configMap: slideInUp,text: "slideInUp",autoPlay: true,),
83+
AnimatedCell(configMap: slideInDown,text: "slideInDown",autoPlay: true,),
84+
AnimatedCell(configMap: slideInLeft,text: "slideInLeft",autoPlay: true,),
85+
AnimatedCell(configMap: slideInRight,text: "slideInRight",autoPlay: true,),
86+
AnimatedCell(configMap: slideOutUp,text: "slideOutUp"),
87+
AnimatedCell(configMap: slideOutDown,text: "slideOutDown"),
88+
AnimatedCell(configMap: slideOutLeft,text: "slideOutLeft"),
89+
AnimatedCell(configMap: slideOutRight,text: "slideOutRight"),
90+
AnimatedCell(configMap: lightSpeedIn,text: "lightSpeedIn",autoPlay: true,curve: lightSpeedInCurve,),
91+
AnimatedCell(configMap: lightSpeedOut,text: "lightSpeedOut",curve: lightSpeedOutCurve,),
92+
];
93+
5794
class MyHomePage extends StatefulWidget {
5895
@override
5996
_MyHomePageState createState() => _MyHomePageState();
6097
}
6198

6299
class _MyHomePageState extends State<MyHomePage> {
100+
101+
@override
102+
void reassemble() {
103+
// TODO: implement reassemble
104+
super.reassemble();
105+
setState(() {
106+
107+
});
108+
}
63109
@override
64110
Widget build(BuildContext context) {
65111
return Scaffold(
66112
appBar: AppBar(
67113
title: Text("Animation"),
68114
),
69-
body: Column(
70-
children: <Widget>[
71-
AnimatedCell(),
72-
],
115+
body: SingleChildScrollView(
116+
child: Column(
117+
children: cells,
118+
),
73119
),
74120
);
75121
}

0 commit comments

Comments
 (0)