You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The UI package includes a `widgetbook/` submodule — a standalone Flutter app powered by [Widgetbook](https://pub.dev/packages/widgetbook) that serves as both a **developer sandbox** for building widgets in isolation and a **showcase** for browsing every widget in the package.
417
+
418
+
### Catalog Structure
419
+
420
+
```
421
+
my_ui/
422
+
├── lib/
423
+
│ └── ... # UI package source
424
+
├── widgetbook/ # Catalog submodule
425
+
│ ├── lib/
426
+
│ │ ├── main.dart # Entry point — runs WidgetbookApp
427
+
│ │ └── widgetbook/
428
+
│ │ ├── widgetbook.dart # WidgetbookApp widget with addons
429
+
│ │ ├── widgetbook.directories.g.dart # Generated — do not edit
430
+
│ │ ├── use_cases/
431
+
│ │ │ ├── app_button.dart # Use cases for AppButton
432
+
│ │ │ ├── app_card.dart
433
+
│ │ │ └── ... # One file per widget
434
+
│ │ └── widgets/
435
+
│ │ ├── widgets.dart # Barrel file for catalog helpers
436
+
│ │ └── use_case_decorator.dart # Wrapper for consistent presentation
Each widget gets a dedicated file in `use_cases/` with one or more `@widgetbook.UseCase` annotations. Each use case is a top-level function that returns a `Widget`:
559
+
560
+
```dart
561
+
import 'package:flutter/material.dart';
562
+
import 'package:my_ui/my_ui.dart';
563
+
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
Widgetbook uses `build_runner` to scan `@widgetbook.UseCase` annotations and generate the `widgetbook.directories.g.dart` file. Run the generator after adding or modifying use cases:
619
+
620
+
```bash
621
+
cd widgetbook && dart run build_runner build --delete-conflicting-outputs
0 commit comments