Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Hello all!! In this blog we will learn that how can we done the Navigation without passing context in Flutter.
As we all know that we need to pass context while we are navigating in our application from one screen to another.But sometime we got some context issues.So without getting frustrate from that context issue we can make a global key and use it for navigation.
Check our Flutter app development services page.
So without wasting time, let’s begin the code implementation.
For the implementation of navigation without passing context, firstly we will create a global navigation key in our main.dart file as shown in below code snippet.
After creating global navigation key, now we only need to use this key where we want to navigate on another screen.Also if we are getting some context issues while navigation we can use this key.
As it is global key we can call it in any of the file.
As shown in below code snippet we are using global navigation key for navigation.
Here we are using the navigatorKey as context and passing it in the place of context.
Not only in navigation, we can also use this key in all the context required places as it is global key.
Now we are done with our implementation of Navigation in our app without passing context.It will be very beneficial when we are facing some issues related to context and unable to navigate.
or we are getting some issues while navigating ,there we can define global navigation key and use it wherever we want to navigate.
It is also more useful as we are not using any package or dependency in our implementation.
Congratulations!!!! We have implemented Navigation without passing context in flutter.
For more interesting blogs check out here – https://mobikul.com/blog/
Thanks for reading.😇
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.