How to Fix “The method ‘MultiTrackTween’ isn’t defined for the type ‘FadeAnimation’.”

If you are on your way in creating a Fade Animation from the simple_animations package which you plan using for your page. Then as you run to your code, you encounter this error on your terminal;

The method 'MultiTrackTween' isn't defined for the type 'FadeAnimation'.
Try correcting the name to the name of an existing method, or defining a method named 'MultiTrackTween'.

You may or may have not used the code above, but if you do. Your error was that the codes you used are outdated. The methods are indeed revised right now. ControlledAnimation, MultiTrackTween, PlayAnimation, and a few more underwent name changes. Please look at the sample below:

enum AniProps { opacity, translateY }

class FadeAnimation extends StatelessWidget {
  final double delay;
  final Widget child;

  FadeAnimation(this.delay, this.child);

  Widget build(BuildContext context) {
    final tween = MultiTween<AniProps>()
        ..add(AniProps.opacity, Tween(begin: 0.0, end: 1.0))
        ..add(AniProps.translateY, Tween(begin: -30.0, end: 0.0), Duration(milliseconds: 500), Curves.easeOut);

    return PlayAnimation<MultiTweenValues<AniProps>>(
      delay: Duration(milliseconds: (500 * delay).round()),
      duration: tween.duration,
      tween: tween,
      child: child,
      builder: (context, child, animation) => Opacity(
        opacity: animation.get(AniProps.opacity),
        child: Transform.translate(
            offset: Offset(0, animation.get(AniProps.translateY)),
            child: child

The methods are indeed revised. MultiTrackTween, and ControlledAnimation which are changed into MultiTween, and PlayAnimation, consecutively.

You may refer to packages/simple_animations to read more of the changes and merges that occurred during the updates.

That’s it. Hoping this assist you in Fixing “The Method ‘MultiTrackTween’ Isn’t Defined For The Type ‘FadeAnimation’.“.

Leave a Comment

Your email address will not be published. Required fields are marked *