diff --git a/lib/src/animate_do_attention_seekers.dart b/lib/src/animate_do_attention_seekers.dart index 938845c..735e0f0 100644 --- a/lib/src/animate_do_attention_seekers.dart +++ b/lib/src/animate_do_attention_seekers.dart @@ -90,6 +90,11 @@ class _BounceState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -192,6 +197,11 @@ class _FlashState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -293,6 +303,11 @@ class _PulseState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -417,6 +432,11 @@ class _SwingState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -523,6 +543,11 @@ class _SpinState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -617,6 +642,11 @@ class _SpinPerfectState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -719,6 +749,11 @@ class _DanceState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -819,6 +854,11 @@ class _RouletteState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_bounces.dart b/lib/src/animate_do_bounces.dart index ccf95c6..f9234c3 100644 --- a/lib/src/animate_do_bounces.dart +++ b/lib/src/animate_do_bounces.dart @@ -82,6 +82,11 @@ class _BounceInDownState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -218,6 +223,11 @@ class _BounceInLeftState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_elastics.dart b/lib/src/animate_do_elastics.dart index bc3afbc..ff3d13c 100644 --- a/lib/src/animate_do_elastics.dart +++ b/lib/src/animate_do_elastics.dart @@ -80,6 +80,11 @@ class _ElasticInState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -186,6 +191,11 @@ class _ElasticInDownState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -341,6 +351,11 @@ class _ElasticInLeftState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_fadeouts.dart b/lib/src/animate_do_fadeouts.dart index e64354b..f4bd7f5 100644 --- a/lib/src/animate_do_fadeouts.dart +++ b/lib/src/animate_do_fadeouts.dart @@ -75,6 +75,11 @@ class _FadeOutState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to original + if( !widget.animate ) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: animation, builder: (BuildContext context, Widget? child) { @@ -169,6 +174,11 @@ class _FadeOutDownState extends State controller?.forward(); } + /// If FALSE, animate everything back to original + if( !widget.animate ) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -308,6 +318,11 @@ class _FadeOutUpState extends State controller?.forward(); } + /// If FALSE, animate everything back to original + if( !widget.animate ) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -447,6 +462,11 @@ class _FadeOutLeftState extends State controller?.forward(); } + /// If FALSE, animate everything back to original + if( !widget.animate ) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_fades.dart b/lib/src/animate_do_fades.dart index 4b86a0a..a1147ed 100644 --- a/lib/src/animate_do_fades.dart +++ b/lib/src/animate_do_fades.dart @@ -19,7 +19,7 @@ class FadeIn extends StatefulWidget { FadeIn( {key, required this.child, - this.duration = const Duration(milliseconds: 300), + this.duration = const Duration(milliseconds: 500), this.delay = const Duration(milliseconds: 0), this.controller, this.manualTrigger = false, @@ -39,8 +39,13 @@ class FadeIn extends StatefulWidget { /// FadeState class /// The animation magic happens here class _FadeInState extends State with SingleTickerProviderStateMixin { + /// Animation controller that controls this animation AnimationController? controller; + + /// is the widget disposed? bool disposed = false; + + /// Animation movement value late Animation animation; @override @@ -72,10 +77,18 @@ class _FadeInState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { + + /// Launch the animation ASAP or wait if is needed if (widget.animate && widget.delay.inMilliseconds == 0) { controller?.forward(); } + /// If the animation already happen, we can animate it back + if (!widget.animate) { + controller?.animateBack(0); + } + + /// Builds the animation with the corresponding return AnimatedBuilder( animation: animation, builder: (BuildContext context, Widget? child) { @@ -129,10 +142,17 @@ class FadeInDown extends StatefulWidget { class _FadeInDownState extends State with SingleTickerProviderStateMixin { AnimationController? controller; + + /// is the widget disposed? bool disposed = false; + + /// animation movement late Animation animation; + + /// animation opacity late Animation opacity; + @override void dispose() { disposed = true; @@ -160,9 +180,11 @@ class _FadeInDownState extends State }); } + /// Returns the controller if the user requires it if (widget.controller is Function) { widget.controller!(controller!); } + } @override @@ -171,6 +193,11 @@ class _FadeInDownState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -269,10 +296,19 @@ class FadeInUp extends StatefulWidget { /// The animation magic happens here class _FadeInUpState extends State with SingleTickerProviderStateMixin { + + /// Animation controller if requested AnimationController? controller; + + /// widget is disposed? bool disposed = false; + + /// Animation movement late Animation animation; + + /// Animation opacity late Animation opacity; + @override void dispose() { disposed = true; @@ -310,6 +346,11 @@ class _FadeInUpState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -450,6 +491,11 @@ class _FadeInLeftState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -590,6 +636,11 @@ class _FadeInRightState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_flips.dart b/lib/src/animate_do_flips.dart index 63b5ed6..42d2714 100644 --- a/lib/src/animate_do_flips.dart +++ b/lib/src/animate_do_flips.dart @@ -80,6 +80,11 @@ class _FlipInXState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -174,6 +179,11 @@ class _FlipInYState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_slides.dart b/lib/src/animate_do_slides.dart index 4e6174d..5ed2af5 100644 --- a/lib/src/animate_do_slides.dart +++ b/lib/src/animate_do_slides.dart @@ -79,6 +79,11 @@ class _SlideInUpState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { @@ -212,6 +217,11 @@ class _SlideInLeftState extends State controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_specials.dart b/lib/src/animate_do_specials.dart index 49c9776..2fb870e 100644 --- a/lib/src/animate_do_specials.dart +++ b/lib/src/animate_do_specials.dart @@ -80,6 +80,11 @@ class _JelloInState extends State with SingleTickerProviderStateMixin { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } + return AnimatedBuilder( animation: controller!, builder: (BuildContext context, Widget? child) { diff --git a/lib/src/animate_do_zooms.dart b/lib/src/animate_do_zooms.dart index d4a7ee0..f6a4fdf 100644 --- a/lib/src/animate_do_zooms.dart +++ b/lib/src/animate_do_zooms.dart @@ -80,6 +80,10 @@ class _ZoomInState extends State with SingleTickerProviderStateMixin { if (widget.animate && widget.delay.inMilliseconds == 0) { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } return AnimatedBuilder( animation: fade, @@ -176,6 +180,10 @@ class _ZoomOutState extends State with SingleTickerProviderStateMixin { if (widget.animate && widget.delay.inMilliseconds == 0) { controller?.forward(); } + /// If FALSE, animate everything back to the original state + if (!widget.animate) { + controller?.animateBack(0); + } return AnimatedBuilder( animation: controller!, diff --git a/pubspec.lock b/pubspec.lock index 03307d6..e15edce 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,35 +21,28 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -66,21 +59,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -113,34 +113,27 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0"