[Flutter] There are multiple heroes that share the same tag within a subtree.

김지훈·2024년 4월 1일
0

오류사냥

목록 보기
3/3

페이지를 하나 만들어 놓고, 다른 페이지로 이동하니까
아래 오류가 발생했다.

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#b5dae

번역기를 샥 돌려보니,

Hero가 애니메이션화될 각 하위 트리(예: PageRoute 하위 트리) 내에서 
각 Hero에는 null이 아닌 고유한 태그가 있어야 합니다.

라고한다.

뭔가 말이 복잡한데
간단하게, 구별이 안되니 고유한 태그를 지정해야 한다~ 그런 소리였다.

문제가 되는 지점은 오류메세지 하단에 보이듯이 FloatingActionButton 이었다.
heroTag 속성을 사용해서 FloatingActionButton마다 각각의 다른 태그를 지정해줬다.

FloatingActionButton(
                  heroTag: 'FloatingButton',
                  ...
                  )

끗!

0개의 댓글