Search code examples
flutterflutter-getx

How do I observe a value change in a GetxController class and trigger navigation in the statelessWidget class using GetX in Flutter?


Im in a scenario that I need to receive data on a async task, then decide wether to navigate to the next page or not based on the replying.

But as far as I know, the state management in GetX support widget rebuild when value change in GetxController using .obs and obx().

What should I do to observe the value change then trigger the navigation?


Solution

  • It turns out a simple ever<T> method inherited from the GetxController class do the trick.

    And it turns out that you shouldn't hybrid provider, get_it and get_x all together. Bring lots of unnecessary pain which will cause some of the feature in get_x not working.