Skip to content

Build & Run

Efra Espada edited this page May 3, 2023 · 8 revisions

Building your catalog

Once your previews are ready, build your catalog page.

flutter pub run catalog:build && dart format lib/*
   lib
    |
    |-- ui
        |
        |-- catalog
            |
            |-- catalog_component.dart                  <-- catalog created
            |
            |-- sized
            |   |
            |   |-- container
            |   |   |
            |   |   |-- sized_container.dart    <-- widget page created
            |   |
            |   |-- sized_preview_page_dummy.dart
            |
            |-- images
                |
                |-- gsImage
                |   |
                |   |-- gsImage.dart    <-- widget page created
                |
                |-- images_preview_page_dummy.dart

Notice the catalog creation path is defined in pubspec.yaml (in this sample /lib/ui/catalog/)

Notice the catalog-page creation path is defined in @Preview and pubspec.yaml (in this sample /catalog/sized/container)

Run with go_router

final router = GoRouter(
  routes: [
    // ... other routes
    
    // add the catalog route in debug mode (can be run in release, but it is not recommended)
    if (kDebugMode) CatalogComponent.route,
  ],
);

Notice CatalogComponent class name is defined in pubspec.yaml

Run without go_router

Wrap your main app widget with:

runApp(
  CatalogRunner(
    args: args,
    enabled: true,
    application: MyApp(),
    route: CatalogComponent.route,
  ),
);

Notice CatalogComponent class name is defined in pubspec.yaml

For running your catalog you can:

  • Use the enabled parameter as true to force the catalog.

  • Include catalog as flutter argument: flutter run -d linux -a catalog

Clone this wiki locally