0

I was reading here about navigate with named routes, and in the document itself it says that it is no longer recommended to use it in many applications. Can anyone recommend me what is correct to use now? Or some article talking about.

krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88

1 Answers1

1

Flutter docs suggests using go_router package for Navigation.

Explanation:

Limitations of trivial approach

Although named routes can handle deep links, the behavior is always the same and can’t be customized. When a new deep link is received by the platform, Flutter pushes a new Route onto the Navigator regardless where the user currently is.

Suggested Better Approach

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.


Reference questions regarding go_router:

krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88
  • Whilst this is the recommended approach, GoRouter has significant limitations with nesting and maintaining state. The workaround while clever is very much a hack and not supportive of many use cases. GoRouter isn't sufficiently able to replace the scenarios of multiple Navigators at this moment in time and the talk of managing state correctly has been in development for over a year now still without a release. There are alternatives, Beamer, Routemaster AdvancedRouter for example. All have their pros and cons of course. – Walrus Apr 01 '23 at 09:23