Web History

Sometimes you don't want the browser tracking history when you navigate. In that case, go_router supports Router.neglect.

  // turn off history tracking in the browser for this navigation
  onPressed: () => Router.neglect(context, () => context.go('/page2'))},

The use of Router.neglect will stop the Flutter router from adding this page to the browser history. If you'd like the browser to stop tracking history altogether for your app, set the routerNeglect parameter of the GoRouter constructor. This will suppress history for all navigation made using go_router.

final _router = GoRouter(
  // turn off history tracking in the browser for all navigation
  routerNeglect: true,

Even when you ask the router to neglect to add navigation to the brower's history, deep and dynamic linking will continue to work and the brower's address bar will update as you navigate through your app. It's only the browser's Back button that will be affected.