In the same official docs you have provided there is link for the go_router
, which is preferred by flutter team
You can use the path
property of GoRoute
to achieve the desired url
Initial setup:
// GoRouter configuration
final _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => HomeScreen(),
),
GoRoute(
path: '/secondRoute', // here you can add the path
builder: (context, state) => SecondScreen(), // This is the desired screen you would want to go to
),
],
);
Now your url when routing to SecondScreen
would be http://localhost:37291/#/secondRoute
If you want to have the very same functionality you had with Navigator
stack you need to implement stuff around Router
class. Find out more in this article. You could possibly refer this article for the same.
Further reference:
Flutter: go_router how to pass multiple parameters to other screen?