Dynamic URLs
Learn how to use web-like URL syntax to navigate dynamically.
Overview
The best feature of Flutter is that it is platform agnostic. We can run Flutter apps on any platform. However, each platform has some quirks. For example, the long URL strings on websites are pretty tricky to implement in a Flutter web app.
https://www.educative.io/profile?user=Aachman&author=yes
GetX offers a straightforward method to use URL syntax for navigation in Flutter apps. Not only the parameters appear in the address bar, they can be retrieved in the routes to create dynamic widgets.
Dynamic named routes
We know how we can define named routes. They look something like this:
GetPage(name: '/profile', page: () => ProfilePage()),
The code above shows a static named route. A static named route refers to the one with a fixed path, which in this case is '/profile'
. This can be limiting when we want to create dynamic routes based on data. For example, navigating to a user’s profile page based on their name. In this case, the path needs to contain the user’s name. But we cannot define all those paths manually because there can be any number of users.
This is when dynamic named routes come into the picture. Dynamic named routes allow us ...