@@ -31,11 +31,15 @@ class GFAnimation extends StatefulWidget {
3131 this .fontWeight,
3232 this .changedWidth,
3333 this .changedHeight,
34+ this .reverseDuration,
3435 }) : super (key: key);
3536
3637 /// The duration for animations of the [Decoration] .
3738 final Duration duration;
3839
40+ /// The duration for animations of the type[Size] .
41+ final Duration reverseDuration;
42+
3943 /// Defines how the animated widget is aligned within the Animation.
4044 final Alignment alignment;
4145
@@ -203,27 +207,40 @@ class _GFAnimationState extends State<GFAnimation>
203207 child: AnimatedAlign (
204208 curve: widget.curve ?? Curves .linear,
205209 alignment: selected
206- ? widget.alignment ?? Alignment .center
207- : Alignment .topCenter,
210+ ? widget.activeAlignment ?? Alignment .center
211+ : widget.alignment ?? Alignment .topCenter,
208212 duration: widget.duration ?? const Duration (seconds: 2 ),
209213 child: widget.child,
210214 ),
211215 ),
212216 );
213217
214218 Widget buildAnimatedSizeWidget () => GestureDetector (
215- onTap: widget.onTap,
216- child: Container (
217- margin: widget.margin ?? const EdgeInsets .all (0 ),
218- padding: widget.padding ?? const EdgeInsets .all (0 ),
219- color: widget.color ?? Colors .white,
220- child: AnimatedSize (
221- alignment: widget.alignment ?? Alignment .center,
222- curve: widget.curve ?? Curves .linear,
223- vsync: this ,
224- duration: widget.duration ?? const Duration (milliseconds: 2000 ),
225- child: widget.child,
226- ),
219+ onTap: () {
220+ if (widget.onTap == null ) {
221+ if (mounted) {
222+ setState (() {
223+ selected = ! selected;
224+ });
225+ }
226+ } else {
227+ widget.onTap ();
228+ }
229+ },
230+ child: AnimatedSize (
231+ alignment: widget.alignment ?? Alignment .center,
232+ curve: widget.curve ?? Curves .linear,
233+ vsync: this ,
234+ reverseDuration:
235+ widget.reverseDuration ?? const Duration (milliseconds: 2000 ),
236+ duration: widget.duration ?? const Duration (milliseconds: 2000 ),
237+ child: Container (
238+ margin: widget.margin ?? const EdgeInsets .all (0 ),
239+ padding: widget.padding ?? const EdgeInsets .all (0 ),
240+ color: widget.color ?? Colors .white,
241+ height: selected ? widget.height ?? 200 : widget.height ?? 100 ,
242+ width: selected ? widget.width ?? 200 : widget.width ?? 100 ,
243+ child: widget.child),
227244 ),
228245 );
229246
0 commit comments