Skip to main content
Cinemapedia uses GoRouter for declarative, URL-based navigation. The router configuration is defined in lib/config/router/app_router.dart and exported as the appRouter instance.

Router configuration

The MovieScreen route is nested under HomeScreen, making its full resolved path /movie/:id.

Routes

The movieId path parameter

The :id segment in /movie/:id is a named path parameter. GoRouter extracts it from state.pathParameters:
The movieId string is passed directly to MovieScreen as a required constructor parameter:
If the :id parameter is missing or cannot be parsed, the router falls back to the string 'no-id'.
Navigation from a list item to the detail screen is triggered by a GestureDetector tap inside MovieHorizontalListview. It uses GoRouter’s context.push() with the movie’s ID interpolated into the path:
1

User taps a movie poster

The GestureDetector in _Slide (inside MovieHorizontalListview) fires its onTap callback.
2

GoRouter pushes the detail route

context.push('/movie/${movie.id}') adds /movie/:id on top of the current navigation stack, keeping HomeScreen in the back stack.
3

MovieScreen receives the ID

GoRouter extracts the :id segment and passes it to MovieScreen as movieId.

Route name constants

Both screens define a static name constant that is referenced in the router config. Using the constant instead of a raw string prevents typos and makes renaming safer: