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

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

概述我在一行中生成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 fo 我在一行中生成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),
总结

以上是内存溢出为你收集整理的routes – 在Row抛出错误的相同颤振窗口小部件?全部内容,希望文章能够帮你解决routes – 在Row抛出错误的相同颤振窗口小部件?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1000582.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存