Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the CurvedAnimation in Flutter on controller reverse?

When an Animation controller is set forward(), I want the Animation attached to it to have a CurvedAnimation of Curves.elasticIn

When an Animation controller is set reverse(), I want the Animation attached to it to have a CurvedAnimation of Curves.elasticOut

I thought of changing the Curve just before the animation but it does not change it.

This is my attempt:

   if (!pinDropAnimationController.isAnimating) {
          if (mapController.isCameraMoving) {
            pinDropAnimationTween.animate(
                new CurvedAnimation(
                    parent: pinDropAnimationController, curve: Curves.linear));
            pinDropAnimationController.forward();
          } else {
            pinDropAnimationTween.animate(
                new CurvedAnimation(
                    parent: pinDropAnimationController, curve: Curves.elasticIn));
            pinDropAnimationController.reverse();
          }
         }
   }
like image 252
TSR Avatar asked Oct 22 '25 05:10

TSR


1 Answers

On the CurvedAnimation constructor you have an argument named reverseCurve !

It does the job really well :)

like image 189
Mathis N Avatar answered Oct 25 '25 13:10

Mathis N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!