Step 1 / 5
Routes are paths
Each GoRoute maps a URL path to a builder. The app's whole navigation map lives in one place.
Describe screens as URL paths so web links, deep links and the browser back button just work.
1final router = GoRouter(2 routes: [3 GoRoute(4 path: '/',5 builder: (context, state) => const HomePage(),6 routes: [7 GoRoute(8 path: 'product/:id',9 builder: (context, state) =>10 ProductPage(id: state.pathParameters['id']!),11 ),12 ],13 ),14 ],15);1617void main() => runApp(MaterialApp.router(routerConfig: router));1819// Navigate by URL from anywhere20context.go('/product/42');21context.push('/product/42'); // keeps the back stack
Each GoRoute maps a URL path to a builder. The app's whole navigation map lives in one place.