加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

routes – 在Row抛出错误的相同颤振窗口小部件?

发布时间:2020-12-14 14:50:29 所属栏目:百科 来源:网络整理
导读:我在一行中生成2个FloatingActionButtons.路由到其文件时出现以下错误… The following assertion was thrown during a scheduler callback: There are multiple heroes that share the same tag within a subtree. Within each subtree for which heroes ar
我在一行中生成2个FloatingActionButtons.路由到其文件时出现以下错误…

The following assertion was thrown during a scheduler callback:
There are multiple heroes that share the same tag within a subtree.
Within each subtree for which heroes are to be animated (typically a PageRoute subtree),each Hero
must have a unique non-null tag.
In this case,multiple heroes had the tag “Instance of ‘Object'”.

这是我的代码……

new Row(
              mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
                new FloatingActionButton(
                    child: new Icon(Icons.remove),onPressed: _decline),new Padding(padding: new EdgeInsets.all(10.0)),new Text(
                  _count.toString(),style: new TextStyle(
                      fontSize: 40.0,fontWeight: FontWeight.bold,color: Colors.black),),new FloatingActionButton(
                    child: new Icon(Icons.add),onPressed: _increment),],)

这是我如何路由到我的文件…

Navigator.push(context,new MaterialPageRoute(builder:(_)=> new Video.VideoPage()));

当我注释掉第一个FloatingActionButton时它工作正常.只有当它们都被使用时它才会出错.如果重要的话,My Row也是Column小部件的子代.

解决方法

尝试为每个FloatingActionButtons添加一个唯一的 heroTag,这样Flutter就不会将这两个按钮相互混淆,例如:

new Row(
        mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
          new FloatingActionButton(
              heroTag: "Decline",child: new Icon(Icons.remove),new Text(
            _count.toString(),style: new TextStyle(
                fontSize: 40.0,new FloatingActionButton(
              heroTag: "Increment",child: new Icon(Icons.add),

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读