Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get.to(MyPage()) - How to remove all previous routes - Flutter GetX

I have a simple Flutter app and I want to remove all previous routes but I want to do with GetX, How to do that?

Now it works with

Navigator.of(context).pushNamedAndRemoveUntil('/home', (Route<dynamic> route) => false);

But I want to know the correct way with Get.to or similar

like image 855
Álvaro Agüero Avatar asked Nov 27 '22 19:11

Álvaro Agüero


2 Answers

Get.offAll(Home());

of with namedRoutes:

Get.offAllNamed('/home');

More info on docs: https://github.com/jonataslaw/getx/blob/master/documentation/en_US/route_management.md

like image 64
jonatas Borges Avatar answered Dec 22 '22 11:12

jonatas Borges


If you want remove last page then use it.

Get.off(Home());

If you want remove all previous page then use it.

Get.offAll(Home());

just simple

like image 38
Jewel Rana Avatar answered Dec 22 '22 11:12

Jewel Rana