Historical source · 2021–2022
Original guide · Debugging Your Routes
Preserved original documentation, with its original version context.
On this page
Debugging Your Routes
Because go_router asks that you provide a set of paths, sometimes as fragments to match just part of a location, it's hard to know just what routes you have in your app. In those cases, it's handy to be able to see the full paths of the routes you've created as a debugging tool, e.g.
GoRouter: known full paths for routes:
GoRouter: => /
GoRouter: => /family/:fid
GoRouter: => /family/:fid/person/:pid
GoRouter: known full paths for route names:
GoRouter: home => /
GoRouter: family => /family/:fid
GoRouter: person => /family/:fid/person/:pidLikewise, there are multiple ways to navigate, e.g. context.go(), context.goNamed(), context.push(), context.pushNamed(), the Link widget, etc., as well as redirection, so it's handy to be able to see how that's going under the covers, e.g.
GoRouter: setting initial location /
GoRouter: location changed to /
GoRouter: getting location for name: "person", params: {fid: f2, pid: p1}
GoRouter: going to /family/f2/person/p1
GoRouter: location changed to /family/f2/person/p1Furthermore, if you use the builder instead of the pageBuilder method to create a screen in your app, go_router will look for the app type to determine what transitions to provide to your pages:
GoRouter: MaterialApp foundAnd finally, if there's an exception in your routing, you'll see that in the debug output, too, along with the call stack, e.g.
GoRouter: Exception: no routes for location: /foobarquux
...call stack elided...To enable this kind of output when your GoRouter is first created, you can use the debugLogDiagnostics argument:
final _router = GoRouter(
routes: ...,
// log diagnostic info for your routes
debugLogDiagnostics: true,
);This parameter defaults to false, which produces no output.
Sources & version context
GoRouter.dev documentation edition. The preserved text describes the original package APIs. Follow the current guide before using it in a new project.