kPreviewEnabled top-level constant
Compile-time switch for the preview catalog.
Defaults to kDebugMode: ON in debug builds, OFF in profile and release
(kDebugMode is false in both). A profile build can opt in with
--dart-define=PREVIEW_ENABLED=true; a debug build can force it off with
--dart-define=PREVIEW_ENABLED=false. Release is always blocked by the
kReleaseMode guard in MagicPreview.registerRoutes regardless. Because
this is a const, the release-mode optimizer can fold the guarded branch in
MagicPreview.registerRoutes dead and tree-shake the entire catalog,
every PreviewEntry, and every builder it transitively references.
release-mode optimizer can fold the guarded branch in
MagicPreview.registerRoutes dead and tree-shake the entire catalog,
every PreviewEntry, and every builder it transitively references.
Implementation
const bool kPreviewEnabled = bool.fromEnvironment(
'PREVIEW_ENABLED',
defaultValue: kDebugMode,
);