Flutter <default FloatingActionButton tag> 异常

396 阅读1分钟
I/flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter: The following assertion was thrown during a scheduler callback:
I/flutter: There are multiple heroes that share the same tag within a subtree.
I/flutter: Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter: have a unique non-null tag.
I/flutter: In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
I/flutter: Here is the subtree for one of the offending heroes:
I/flutter: # Hero(tag: <default FloatingActionButton tag>, state: _HeroState#c0b28)

大致意思是说: 在程序回调的的时候发生了以下断言: 在子树中有多个Hero 对象共用了一个tag,每个Hero对象的tag必须是惟一的。

并且指出了是FloatingActionButton中的tag 有冲突。

以前都没注意到这个东西,来看一下FloatingActionButton 中的 tag吧。

在每一个FloatingActionButton加上 heroTag 就可以了。