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
In my case, it likes a hot reload bug. Just restart debugging works for me.
Make sure that you don't have a Form
parent and a Form
child with the same key
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.
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>();