首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AnimateBuilder不接受AnimationController的可列表参数动画

AnimateBuilder不接受AnimationController的可列表参数动画
EN

Stack Overflow用户
提问于 2022-02-05 15:26:48
回答 1查看 79关注 0票数 0

在这儿跳起舞。我用的是吐温和AnimationController。我正在尝试使用动画片()方法。

错误说明如下

参数类型为“AnimationController?”不能分配给参数类型'Listenable‘

我用过的代码

代码语言:javascript
复制
Animation<double>? containerSize;
AnimationController? animationController;
Duration animationDuration = Duration(microseconds: 270);

initState方法:

代码语言:javascript
复制
    void initState(){
       super.initState();
       SystemChrome.setEnabledSystemUIOverlays([]);
       animationController = AnimationController(vsync: this, duration: animationDuration);
   }

在Widget中声明的吐温方法:

代码语言:javascript
复制
containerSize = Tween<double>(begin: size.height * 0.1, end: defaultRegisterSize).animate(CurvedAnimation(parent: animationController!, curve: Curves.linear));

AnimateBuiler里面的脚手架->身体->堆栈->孩子

代码语言:javascript
复制
//Register container
          AnimatedBuilder(
            animation: animationController,
            builder: (context, child){
              return buildRegisterContainer();
            },
          )

呼叫Inkwell->GestureDetector

代码语言:javascript
复制
GestureDetector(
          onTap: (){
            animationController?.forward();

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

如何将AnimationController赋值给AnimateBuilder的动画参数?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-05 15:30:06

添加!使其非空,如下所示:

代码语言:javascript
复制
  AnimatedBuilder(
    animation: animationController!,
    builder: (context, child){
       return buildRegisterContainer();
    },
  )
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70999400

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档