Routing Using Get
08 Jul 2020Routing in Flutter can be easy for small apps, but when you have quite a few pages you know that you need to manage them properly. Flutter gives you quite a few ways to do that, you might be doing it by using named routes or a package like auto_route. For this article, we’ll be using GET.
GET, Router
GET is not just a simple Routing solution but a Micro-Framework for Flutter. It has quite a lot that we can do with it like Dependency Management, State Management, Utils/Helpers and more.
Routing
We’ll start by creating a new Flutter project.
Importing Package
In pubspec.yaml import GET package. pubspec will then look something like this:
Base Setup
In your main.dart rename MaterialApp to GetMaterialApp.
Create a routes.dart file
Now simply call Get.toNamed to navigate to a page or Get.offNamed to push to new page and replace current page.
Previous Articles on GET
Upcoming Articles
I’ll be writing a list of Articles that will cover almost everything that we can do with GET namingly:
- Dependency Management
- Other Fun Helpers/Utilities (SnackBars, Dialog, BottomSheet etc)
- Architecture using GET
Hope it helps.