Search code examples
flutterdartroutesflutter-getx

How to properly navigate to previous page with getx?


I have a pages A>B>C>D>E I want to navigate back from page E>B>A

I tried with

 Get.offNamedUntil('B', (route) => false);

But it worked like E>B and then doesn't redirect back to A. Is there any other way to do so?


Solution

  • I would say that you forget a / in the named route, and as a recommendation, don't return false in the callback, set a condition to stop if the named route was not found in the routes stack, as example use route.isFirst :

    Get.offNamedUntil('/B', (Route<dynamic> route) => route.isFirst);