preview library

Magic dev-only component preview catalog barrel.

Import this file to host the auto-discovered component previews behind two plain pages (/preview and /preview/:component). The whole surface is dev-only: it is reachable only through MagicPreview.registerRoutes, which is guarded by kReleaseMode + bool.fromEnvironment('PREVIEW_ENABLED') and tree-shaken from release builds.

Wiring (in the consumer's RouteServiceProvider.boot(), which runs BEFORE MagicRouter.instance.routerConfig is first accessed — the router locks its route table on that first access):

@override
Future<void> boot() async {
  registerAppRoutes();
  if (kDebugMode) {
    MagicPreview.register(previewEntries()); // from _previews.g.dart
    MagicPreview.registerRoutes();
  }
}

See src/preview/magic_preview.dart for the PreviewEntry contract and the MagicPreviewCatalog widget, and src/preview/preview_routes.dart for the MagicPreview registration entrypoint and the release boundary.

Classes

MagicPreview
The dev-only preview registration entrypoint.
MagicPreviewCatalog
The dev-only component preview catalog.
PreviewEntry
A single entry in the MagicPreviewCatalog.

Constants

kPreviewEnabled → const bool
Compile-time switch for the preview catalog.