I am using bottom navigation bar which contains global key which i have been intialized in home controller. I am routing my page like from page1 to page 2 and page 3 and now from page 3 i am routing back to home page then it throws the error below:

ch=false

Another exception was thrown: Multiple widgets used the same GlobalKey.

Another exception was thrown: Multiple widgets used the same GlobalKey.

Another exception was thrown: Multiple widgets used the same GlobalKey.


Solution 1: S. M. JAHANGIR

Move all the keys and Flutter related imports on the widget. It's not recommended to use any UI code inside your logic layer(GetxController). It may seem to you that Keys and TextEdittingControllers are logic layer objects, but they are not. They are UI/Flutter layer object.

And always keep in mind that, lifecycles of Flutter and GetX isn't exactly same. So it's always better to use any Flutter disposable interfaces (Keys, Controllers and not GetX controllers) in the widget.