Skip to content

Build & Run

Efra Espada edited this page Oct 6, 2024 · 8 revisions

Building your catalog

Once you have generated the previews of your widgets and their respective dummies you can create the component catalog. Once the catalog is created you will only have to choose how to display it (it will depend on whether you use go_router or not).

dart run catalog:build

The catalog will be positioned in the location of your choice. This point can be configured from the pubspec.yaml.

You can check an example here.

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(
    enabled: true,   // <-- or use (--dart-define catalog=true) in command line
    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 --dart-define catalog=true