Skip to content
Guest
Flutter · Course Syllabus Show lessons
Interaction & Nav · 9 min read · Beginner

Declarative Navigation with GoRouter

Navigate cleanly between screens, pass route parameters, and support deep links using go_router.

What you'll learn

  • Define typed routes and nested shells with GoRouter
  • Navigate with context.go() vs context.push()
  • Handle auth redirects cleanly in one place

Overview

Navigate cleanly between screens, pass route parameters, and support deep links using go_router.

Code Example

final router = GoRouter(
  routes: [
    GoRoute(path: '/', builder: (_, __) => const HomeScreen()),
    GoRoute(path: '/course/:slug', builder: (_, s) => CourseScreen(slug: s.pathParameters['slug']!)),
  ],
);

Key Takeaways

  • Define typed routes and nested shells with GoRouter
  • Navigate with context.go() vs context.push()
  • Handle auth redirects cleanly in one place

Quick Check

Check Your Understanding

Score: 0 / 1

1. What is the difference between `context.go('/details')` and `context.push('/details')` in `go_router`?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind