Week-8-Routing-and-Navigation.docx
Week-8-Routing-and-Navigation.docx
Flutter provides a complete system for navigating between screens and handling deep links. Small
applications without complex deep linking can use Navigator, while apps with specific deep linking and
navigation requirements should also use the Router to correctly handle deep links on Android and iOS,
and to stay in sync with the address bar when the app is running on the web.
Deep linking refers to using a link to direct users to a specific location within a mobile app, rather than
just the app's homepage. It's like a shortcut that takes users directly to the content they're interested in,
instead of making them navigate through the app itself.
The Navigator widget displays screens as a stack using the correct transition animations for the target
platform. To navigate to a new screen, access the Navigator through the route's BuildContext and call
imperative methods such as push() or pop():
Because Navigator keeps a stack of Route objects (representing the history stack), The push() method
also takes a Route object. The MaterialPageRoute object is a subclass of Route that specifies the
transition animations for Material Design.
Applications with simple navigation and deep linking requirements can use the Navigator for navigation
and the MaterialApp.routes parameter for deep links:
Using the Router
Flutter applications with advanced navigation and routing requirements (such as a web app that uses
direct links to each screen, or an app with multiple Navigator widgets) should use a routing package such
as go_router that can parse the route path and configure the Navigator whenever the app receives a new
deep link.
To use the Router, switch to the router constructor on MaterialApp or CupertinoApp and provide it with
a Router configuration.
Homepage.dart
Secondpage.dart
Passing of parameters/arguments between Screens
Step 2: Use the declared variables. To call these variables, use the syntax “widget.<variable name>”. E.g
“widget.message”
Step 3: Provide the required arguments on the screen