Flutter笔记-There are multiple heroes that share the same tag within a subtree
Posted 小溪彼岸
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter笔记-There are multiple heroes that share the same tag within a subtree相关的知识,希望对你有一定的参考价值。
在使用FloatingActionButton时报错了
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
FloatingActionButton(
onPressed: () => _addItem(),
child: Icon(Icons.add),
),
SizedBox(
width: 60,
),
FloatingActionButton(
onPressed: () => _removeItem(),
child: Icon(Icons.remove),
),
],
),
报错内容:
════════ Exception caught by scheduler library ═════════════════════════════════
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 (i.e. a PageRoute subtree), each Hero must have a unique non-null tag.
In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
Here is the subtree for one of the offending heroes: Hero
tag: <default FloatingActionButton tag>
state: _HeroState#2520e
主要问题是在使用多个FloatingActionButton
时heroTag
需是唯一的。
解决方案:
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
FloatingActionButton(
heroTag: 'first',
onPressed: () => _addItem(),
child: Icon(Icons.add),
),
SizedBox(
width: 60,
),
FloatingActionButton(
heroTag: 'second',
onPressed: () => _removeItem(),
child: Icon(Icons.remove),
),
以上是关于Flutter笔记-There are multiple heroes that share the same tag within a subtree的主要内容,如果未能解决你的问题,请参考以下文章
English trip V1 - B 14. There Are Flowers in My Office 我办公室里有花 Teacher:Lamb Key: There be(is/are)
npm 不起作用,总是出现这个错误 -> 错误:找不到模块'are-we-there-yet'
There are no packages available
Linux exit时出现there are stopped jobs