简体   繁体   中英

The method 'ControlledAnimation' isn't defined for the type 'LogoState'

Widget _buildAnimatedLogo() {
return ControlledAnimation( <-- The method 'ControlledAnimation' isn't defined for the type 'LogoState'
  duration: widget.logoAnimationTween.duration,
  tween: widget.logoAnimationTween,
  builder: (context, animation) {
    return Transform.rotate(
      angle: animation["rotation"],
      child: Padding(
        padding: const EdgeInsets.only(
          bottom: 10,
        ),
        child: Container(
          width: animation["size"],
          height: animation["size"],
          child: Image.asset(
            "assets/images/logo.png",
            fit: BoxFit.fitHeight,
          ),
        ),
      ),
    );
  },
);

}

I am using simple_animations: ^3.0.1, not sure if I am using the wrong class "ControlledAnimation"

It looks like the parentheses and braces in the code you pasted are not properly closed. Note that your _buildAnimatedLogo method has no closing squirly brace.

If that is not the issue, it looks like the compiler mixed methods and widgets. It thinks ControlledAnimation is a method, when it looks like it should be a widget. Try setting a prefix to your simple_animations import statement, like this:

import '.../simple_animations.dart' as simple_animations;

then try to call simple_animations.ControlledAnimation instead of ControlledAnimation directly. Try to see if that makes the task easy for the compiler.

You migrated to a newer version.

Change that with ControlledAnimation -> PlayAnimation.

Check the official example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM