spooky-mb

Deprecated

Route Generator

We use auto_route as our routing system as it allow us to:

Adding new route

1. Generate a new view

Currently, We use Flutter MVVM Architecture VScode extension to generate view. To create a view:

  1. From keyboard, press Cmd + Shift + p
  2. Choose: Flutter Architecture: Create Views
  3. Enter your view name, then It’ll automatically create a folder in your lib/views/your_view_name/ that contain:

2. Add view to router

Add your page in lib/core/routes/app_router.dart as following:

@MaterialAutoRouter(
  routes: <AutoRoute>[
    ...
    AutoRoute(
      path: 'books',
      page: BooksView,
      meta: {
        'title': 'Books',
      },
    ),
  ]
)

3. Generate route

From your console, generate them with build_runner:

fvm flutter pub run build_runner build --delete-conflicting-outputs

Usage

AutoRouter.of(context)
context.router

router.push(const BooksRoute())
router.pushNamed('/books')

For complex navigator, read more here: