I encountered a strange problem. There was no exception in my local debugging, but a gray interface appeared online. I initialized it and thought that Getx could not find the corresponding GetxController.
The phenomenon of the problem is: no error will be reported when entering the page for the first time, but an error will be reported after entering the page for the second time. And when you call Get.back() to return to the previous level, an error will be reported only if you enter again. If you return by sliding sideways, no error will be reported.
If Get.back() returns to the upper-level page, waits for 1~2 seconds, and then enters again, no error will be reported. Have you ever encountered such a magical problem? I’m not sure if it has something to do with the life cycle.
My code doesn’t have much logic. My UI interface hierarchy is like this. Class A is the parent view, classes B, C, and D are subviews (separately encapsulated). Then I put a view model in A and find it in B, C, and D.
2
Answers
It’s hard to say without seeing any code. But I think what happens is that the controller got disposed off when navigating to another route/page. What can help then is to use a
lazyPut
in combination withfenix: true
. This way it can be restored after it was disposed. So instead ofor
do this instread:
This Type of error usually occurs when you try to get "GetXControoller" controller without definning it.
For example:
First you need to initialize it