Flutter Navigation Without Context

In Flutter navigation without context between two screens is very easy with the help of Getx package. For more info about Get Package, click here to read our article.

In this blog, you will learn how to navigate one screen to another screen without context. So Let’s get started.

flutter navigation  without context using getx
flutter navigation without context using getx

In the old method we use Navigator. Now we don’t need any lengthy code.

Flutter Navigation without Context

Navigate to a new screen:

Get.to(NextScreen());
Code language: CSS (css)

To close snackbars, dialogs, bottomsheets, 

Get.back();
Code language: CSS (css)

This method is used to go to the next screen and remove the previous screen. This method is helpful when we use SplashScreens, login screens and etc.

Get.off(NextScreen());
Code language: CSS (css)

This method is used to go to the next screen and remove all previous routes. This method is useful when we use shopping carts, polls, and tests, etc.

Get.offAll(NextScreen());
Code language: CSS (css)

Also, Read