今天寫Demo的時候遇到了下面的錯誤:bash
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)
...
複製代碼
大體意思是說:ui
在程序回調的的時候發生瞭如下斷言:this
在子樹中有多個Hero 對象共用了一個tag,每一個Hero對象的tag必須是唯一的。spa
而且指出了是FloatingActionButton
中的tag 有衝突。3d
之前都沒注意到這個東西,來看一下FloatingActionButton 中的 tag吧。 code
<default FloatingActionButton tag>
而恰好個人頁面中有兩個 FloatingActionButton,因此就致使heroTag 衝突了。cdn
歸根到底仍是 Hero對象中的tag必須惟一,從下面報錯的地方就能夠看到了: 對象