Simplifying Navigator 2.0 with GoRouter
Now that we have gotten familiar with how to use GoRouter
we can begin to refactor the Hacker News application to take advantage of its features. First, we need to swap out our demo routes with the actual routes to our application. Inside of app_router.dart
replace GoRouter.routes
with the following:
GoRoute( path: '/', redirect: (_) => '/stories/${StoriesType.newStories.name}', ), GoRoute( path: '/stories/:storyType', builder: (context, state) { final storyTypeName = state.params['storyType'] ?? ...