Navigate without using context in flutter/dart.
Let’s start
Hi coders. Yes, we can navigate without context easily with simple steps. GetX make it simple as well as reliable.
pubspec.yaml
get: ^3.23.1
get dependencies using,
flutter pub get
import
import 'package:get/get.dart';
Now, just replace your MaterialApp
with GetMaterialApp
inside main.dart
void main() {
runApp(GetMaterialApp();
}
Navigate to new screen:
Get.to(NextScreen());
Navigate to new screen with name.
Get.toNamed('/details');
To close snackbars, dialogs, bottomsheets, or anything you would normally close with Navigator.pop(context);
Get.back();
This package helps developers to reduce boilerplates form their code & makes the development faster, i know it will reduces irritation of yours.
That’s why i suggested that !!
Thanks me later.
For Reference go to the link below.
If you like this article, just give me a Clap
Happy Coding !