Skip to content

Routing

We use the package go_router for routing in the app. The go_router package is a declarative router for Flutter that is easy to use and provides a simple API for defining routes. The package is maintained by the flutter team and is actively developed.

Getting started

Go to the lib/core/presentation/routes folder and open the file named go_router.dart. This file contains the configuration for the go_router package.

Define the scratch notes route

Add a new route for the scratch notes feature. The route should point to the ScratchNotesPage widget.

dart
final goRouter = GoRouter(
  initialLocation: SplashPage.route,
  debugLogDiagnostics: true,
  observers: [AnalyticsRouteObserver()],
  routes: [
    ...
    GoRoute(
      name: 'ScratchNotesPage',
      path: ScratchNotesPage.route,
      builder: (context, state) => const ScratchNotesPage(),
    ),
  ],
);

If you want to navigate to the scratch notes page, you can use the following code:

dart
context.go(ScratchNotesPage.route);

Follow the GoRouter documentation for more information on how to use the package: GoRouter Documentation.