Use ‘Get’ navigation manager to switch route /page in Flutter


Heard about Get , a light weight Flutter framework for developing apps with a smart Navigation manager. So what’s make Get Special, Is Flutter has Navigator to do what you want to do ? Yeh. But Get is smart and fast and it is one of the top package on pub.dev

How to use Get

Go to pubspec.yaml file add it as dependecies and also add an import statement to the top of your .dart file.

dependencies:
  flutter:
    sdk: flutter
  get:

import 'package:get/get.dart';

Get can be used to move to another widget page/route or simply calling Get.to . A prerequisite for this is a small change in main, replace the MeterialApp constructor with GetMaterialApp

void main() async {
   runApp(new GetMaterialApp(
    home: new MyApp(),
  ));
}

Suppose I have widget screens like ProductPage, I want to replace conventional flutter way of calling the push with Get.

Navigator.push(context,
     new MaterialPageRoute(builder: (context) => (Product())));

can replace with

Get.to(Product());

Get can be useful on various occasions, I save it for another post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.