Duplicate GlobalKey detected in widget tree

前端 未结 10 1117
孤街浪徒
孤街浪徒 2021-01-03 19:21

I am running into a globalKey error after I navigate from Screen A to Screen B and click a \"Cancel\" button to go back to Scree

相关标签:
10条回答
  • 2021-01-03 19:46

    In my case, it likes a hot reload bug. Just restart debugging works for me.

    0 讨论(0)
  • 2021-01-03 19:47

    Make sure that you don't have a Form parent and a Form child with the same key

    0 讨论(0)
  • 2021-01-03 19:48

    I had a similar problem. in my case the problem was that I had a function in dispose method of screen B and it wouldn't execute properly. I just removed it and the problem was fixed.

    so be sure your dispose method is executed properly in all screens.

    0 讨论(0)
  • 2021-01-03 19:50

    Remove the static and final type from the key variable so if

    static final GlobalKey<FormState> _abcKey = GlobalKey<FormState>();
    

    change it to

    GlobalKey<FormState> _abcKey = GlobalKey<FormState>();
    
    0 讨论(0)
提交回复
热议问题