Cha*_* Jr 5 routes row widget flutter
我在一行中生成2个FloatingActionButtons.路由到其文件时出现以下错误...
在调度程序回调期间抛出以下断言:有多个英雄在子树中共享相同的标记.在每个子树哪位大侠要动画(通常是PageRoute子树),每个英雄必须有一个唯一非空标签.在这种情况下,多个英雄的标签为"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 Padding(padding: new EdgeInsets.all(10.0)),
new FloatingActionButton(
child: new Icon(Icons.add), onPressed: _increment),
],
)
Run Code Online (Sandbox Code Playgroud)
这是我如何路由到我的文件...
Navigator.push(context, new MaterialPageRoute(builder: (_) => new Video.VideoPage()));
当我注释掉第一个FloatingActionButton时它工作正常.只有当它们都被使用时它才会出错.如果重要的话,我Row也是Column小部件的孩子.
尝试heroTag为每个FloatingActionButtons 添加一个唯一的,这样Flutter就不会将这两个按钮相互混淆,例如:
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new FloatingActionButton(
heroTag: "Decline",
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 Padding(padding: new EdgeInsets.all(10.0)),
new FloatingActionButton(
heroTag: "Increment",
child: new Icon(Icons.add), onPressed: _increment),
],
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2142 次 |
| 最近记录: |