11import 'package:flutter/material.dart' ;
2- import 'package:flutter_animation_set/widget/behavior_animations.dart' ;
3- import 'package:flutter_animation_set/widget/transition_animations.dart' ;
42import 'package:flutter_animation_set/animation_set.dart' ;
53import 'package:flutter_animation_set/animator.dart' ;
4+ import 'package:flutter_animation_set/widget/behavior_animations.dart' ;
5+ import 'package:flutter_animation_set/widget/transition_animations.dart' ;
66
77void main () => runApp (AnimatorSetActivity ());
88
@@ -26,7 +26,7 @@ class AnimatorSetState extends State<AnimatorSetActivity> {
2626 slivers: < Widget > [
2727 SliverToBoxAdapter (
2828 child: Padding (
29- padding: EdgeInsets .all (12 .0 ),
29+ padding: EdgeInsets .all (16 .0 ),
3030 child: Text ("Transition Animations" ),
3131 ),
3232 ),
@@ -53,7 +53,7 @@ class AnimatorSetState extends State<AnimatorSetActivity> {
5353 ),
5454 SliverToBoxAdapter (
5555 child: Padding (
56- padding: EdgeInsets .all (12 .0 ),
56+ padding: EdgeInsets .all (16 .0 ),
5757 child: Text ("Behavior Animations" ),
5858 ),
5959 ),
@@ -69,7 +69,7 @@ class AnimatorSetState extends State<AnimatorSetActivity> {
6969 ),
7070 SliverToBoxAdapter (
7171 child: Padding (
72- padding: EdgeInsets .all (12 .0 ),
72+ padding: EdgeInsets .all (16 .0 ),
7373 child: Text ("Leaning Curves" ),
7474 ),
7575 ),
@@ -78,7 +78,7 @@ class AnimatorSetState extends State<AnimatorSetActivity> {
7878 (BuildContext context, int index) {
7979 return box[index];
8080 },
81- childCount: 2 ,
81+ childCount: box.length ,
8282 ),
8383 ),
8484 ],
@@ -89,18 +89,52 @@ class AnimatorSetState extends State<AnimatorSetActivity> {
8989}
9090
9191var box = [
92- BoxColor (
93- child: CurvesLeaning (curve: Curves .linear), color: Color (0xFF000000 )),
94- BoxColor (
95- child: CurvesLeaning (curve: Curves .bounceInOut),
96- color: Color (0xFF000000 )),
92+ CurveBox (curve: Curves .linear, str: "linear" ),
93+ CurveBox (curve: Curves .bounceIn, str: "bounceIn" ),
94+ CurveBox (curve: Curves .bounceInOut, str: "bounceInOut" ),
95+ CurveBox (curve: Curves .bounceOut, str: "bounceOut" ),
96+ CurveBox (curve: Curves .decelerate, str: "decelerate" ),
97+ CurveBox (curve: Curves .ease, str: "ease" ),
98+ CurveBox (curve: Curves .easeIn, str: "easeIn" ),
99+ CurveBox (curve: Curves .easeInSine, str: "easeInSine" ),
100+ CurveBox (curve: Curves .easeInQuad, str: "easeInQuad" ),
101+ CurveBox (curve: Curves .easeInCubic, str: "easeInCubic" ),
102+ CurveBox (curve: Curves .easeInQuart, str: "easeInQuart" ),
103+ CurveBox (curve: Curves .easeInQuint, str: "easeInQuint" ),
104+ CurveBox (curve: Curves .easeInExpo, str: "easeInExpo" ),
105+ CurveBox (curve: Curves .easeInCirc, str: "easeInCirc" ),
106+ CurveBox (curve: Curves .easeInBack, str: "easeInBack" ),
107+ CurveBox (curve: Curves .easeInOut, str: "easeInOut" ),
108+ CurveBox (curve: Curves .easeInOutSine, str: "easeInOutSine" ),
109+ CurveBox (curve: Curves .easeInOutQuad, str: "easeInOutQuad" ),
110+ CurveBox (curve: Curves .easeInOutCubic, str: "easeInOutCubic" ),
111+ CurveBox (curve: Curves .easeInOutQuart, str: "easeInOutQuart" ),
112+ CurveBox (curve: Curves .easeInOutQuint, str: "easeInOutQuint" ),
113+ CurveBox (curve: Curves .easeInOutExpo, str: "easeInOutExpo" ),
114+ CurveBox (curve: Curves .easeInOutCirc, str: "easeInOutCirc" ),
115+ CurveBox (curve: Curves .easeInOutBack, str: "easeInOutBack" ),
116+ CurveBox (curve: Curves .easeOut, str: "easeOut" ),
117+ CurveBox (curve: Curves .easeOutSine, str: "easeOutSine" ),
118+ CurveBox (curve: Curves .easeOutQuad, str: "easeOutQuad" ),
119+ CurveBox (curve: Curves .easeOutCubic, str: "easeOutCubic" ),
120+ CurveBox (curve: Curves .easeOutQuart, str: "easeOutQuart" ),
121+ CurveBox (curve: Curves .easeOutQuint, str: "easeOutQuint" ),
122+ CurveBox (curve: Curves .easeOutExpo, str: "easeOutExpo" ),
123+ CurveBox (curve: Curves .easeOutCirc, str: "easeOutCirc" ),
124+ CurveBox (curve: Curves .easeOutBack, str: "easeOutBack" ),
125+ CurveBox (curve: Curves .elasticIn, str: "elasticIn" ),
126+ CurveBox (curve: Curves .elasticInOut, str: "elasticInOut" ),
127+ CurveBox (curve: Curves .elasticOut, str: "elasticOut" ),
128+ CurveBox (curve: Curves .fastOutSlowIn, str: "fastOutSlowIn" ),
129+ CurveBox (curve: Curves .fastLinearToSlowEaseIn, str: "fastLinearToSlowEaseIn" ),
130+ CurveBox (curve: Curves .slowMiddle, str: "slowMiddle" ),
97131];
98132
99133class BoxColor extends StatefulWidget {
100134 BoxColor ({this .child, this .color = Colors .black});
101135
102- var child;
103- var color;
136+ final child;
137+ final color;
104138
105139 @override
106140 State <StatefulWidget > createState () {
@@ -113,55 +147,81 @@ class BoxColorState extends State<BoxColor> {
113147 Widget build (BuildContext context) {
114148 return Center (
115149 child: Container (
116- padding: EdgeInsets .all (30.0 ),
150+ padding: EdgeInsets .all (30 ),
117151 child: widget.child,
118152 color: widget.color,
119153 ),
120154 );
121155 }
122156}
123157
124- class CurvesLeaning extends StatefulWidget {
125- CurvesLeaning ({this .curve});
158+ class CurveBox extends StatefulWidget {
159+ CurveBox ({this .curve, this .str });
126160
127- Curve curve;
161+ final curve;
162+ final str;
128163
129164 @override
130165 State <StatefulWidget > createState () {
131- return CurvesLeaningState ();
166+ return CurveBoxState ();
132167 }
133168}
134169
135- class CurvesLeaningState extends State <CurvesLeaning > {
170+ class CurveBoxState extends State <CurveBox > {
136171 @override
137172 Widget build (BuildContext context) {
138- return Padding (
139- padding: EdgeInsets .all (12.0 ),
140- child: Flex (
141- direction: Axis .vertical,
142- children: < Widget > [
143- Container (
144- width: MediaQuery .of (context).size.width,
145- child: AnimatorSet (
146- child: SizedBox (
147- child: Container (
148- color: Colors .white,
149- ),
150- width: 20 ,
151- height: 20 ,
152- ),
153- animatorSet: [
154- TX (
155- duration: 2000 ,
156- from: 0.0 ,
157- to: 80.0 ,
158- curve: widget.curve,
159- )
160- ],
161- ),
173+ var _screenWidth = MediaQuery .of (context).size.width;
174+ return Card (
175+ shape: RoundedRectangleBorder (
176+ borderRadius: BorderRadius .all (Radius .circular (12.0 ))),
177+ color: Colors .red,
178+ child: Padding (
179+ padding: EdgeInsets .all (10.0 ),
180+ child: Column (
181+ crossAxisAlignment: CrossAxisAlignment .start,
182+ mainAxisAlignment: MainAxisAlignment .start,
183+ children: < Widget > [
184+ makeCurvesTitleBox (_screenWidth, widget.str),
185+ makeCurvesCube (_screenWidth, 0 , widget.curve),
186+ makeCurvesCube (_screenWidth, 100 , widget.curve),
187+ makeCurvesCube (_screenWidth, 200 , widget.curve),
188+ makeCurvesCube (_screenWidth, 300 , widget.curve),
189+ makeCurvesCube (_screenWidth, 400 , widget.curve),
190+ Divider (height: 10 , color: Colors .white)
191+ ],
162192 ),
163- ],
164- ),
165- );
193+ ));
166194 }
167195}
196+
197+ Widget makeCurvesTitleBox (width, text) {
198+ return SizedBox (
199+ width: width,
200+ height: 15 ,
201+ child: Text (
202+ text.toString (),
203+ style: TextStyle (color: Colors .white, fontSize: 12 ),
204+ ),
205+ );
206+ }
207+
208+ Widget makeCurvesCube (width, delay, curve) {
209+ return AnimatorSet (
210+ child: SizedBox (
211+ child: Container (
212+ color: Colors .white,
213+ width: 20 ,
214+ height: 20 ,
215+ ),
216+ ),
217+ animatorSet: [
218+ TX (
219+ delay: delay,
220+ duration: 2000 ,
221+ from: 0.0 ,
222+ to: width - 50 ,
223+ curve: curve,
224+ )
225+ ],
226+ );
227+ }
0 commit comments