Today's Objective
By the end of this lesson you will understand navigation and routing deeply enough to apply it immediately in real projects.
flutter pub add go_router
// Imperative navigation
Navigator.push(context,
MaterialPageRoute(builder: (_) => const DetailScreen(id: 1)));
// Pass data back
final result = await Navigator.push<String>(context,
MaterialPageRoute(builder: (_) => const InputScreen()));
print(result); // value returned by Navigator.pop(context, 'done')
// GoRouter — declarative routing
final router = GoRouter(
routes: [
GoRoute(path: '/', builder: (_, __) => const HomeScreen()),
GoRoute(
path: '/detail/:id',
builder: (context, state) {
final id = state.pathParameters['id']!;
return DetailScreen(id: int.parse(id));
},
),
],
);
// In main.dart
MaterialApp.router(routerConfig: router)
// Navigate anywhere
context.go('/detail/42');
context.push('/detail/42'); // adds to back stack
Exercise: Build a Multi-Screen App
- Set up GoRouter with Home / List / Detail routes
- Pass an item ID as a path parameter
- Read the param in DetailScreen and display data
- Add a BottomNavigationBar with 2 tabs
- Test the back button on Android and iOS
Day 3 Summary
- Navigator.push adds a screen to the stack
- Navigator.pop returns data to the previous screen
- GoRouter uses URL-like paths for declarative nav
- Path parameters use :name syntax
- BottomNavigationBar persists across pushes
← Previous
State Management
Next →
HTTP and JSON
What's Next
The foundations from today carry directly into Day 4. In the next session the focus shifts to Day 4 — building directly on everything covered here.
Supporting Videos & Reading
Go deeper with these external references.
Day 3 Checkpoint
Before moving on, verify you can answer these without looking:
- What is the core concept introduced in this lesson, and why does it matter?
- What are the two or three most common mistakes practitioners make with this topic?
- Can you explain the key code pattern from this lesson to a colleague in plain language?
- What would break first if you skipped the safeguards or best practices described here?
- How does today's topic connect to what comes in Day 4?
Live Bootcamp
Learn this in person — 2 days, 5 cities
Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.
Reserve Your Seat →
→