Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Listenable Parameter Animation of AnimateBuilder not accepting AnimationController

Flutter Beginner here. I am using Tween with an AnimationController. And I’m trying to use animate() method.

Error Says as follows

The argument type ‘AnimationController?’ can’t be assigned to the parameter type ‘Listenable’

Code I have used

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Animation<double>? containerSize;
AnimationController? animationController;
Duration animationDuration = Duration(microseconds: 270);

initState method:

    void initState(){
       super.initState();
       SystemChrome.setEnabledSystemUIOverlays([]);
       animationController = AnimationController(vsync: this, duration: animationDuration);
   }

Tween Method declared Inside the Widget:

containerSize = Tween<double>(begin: size.height * 0.1, end: defaultRegisterSize).animate(CurvedAnimation(parent: animationController!, curve: Curves.linear));

AnimateBuiler inside the Scaffold->Body->stack->children

//Register container
          AnimatedBuilder(
            animation: animationController,
            builder: (context, child){
              return buildRegisterContainer();
            },
          )

Calling at the Inkwell->GestureDetector

GestureDetector(
          onTap: (){
            animationController?.forward();

            setState(() {
              isLogin = !isLogin;  
            });
          }

How to assign AnimationController to the animation parameter of AnimateBuilder?

>Solution :

Add ! to make it non-null like so:

  AnimatedBuilder(
    animation: animationController!,
    builder: (context, child){
       return buildRegisterContainer();
    },
  )
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading