Production builds
Exclude carp_debug_flutter from release and profile archives, and verify the exclusion.
Make sure the debug toolkit does not ship to end users. Declare carp_debug_flutter as a dev_dependency and reference it only from code gated behind kDebugMode. Flutter then strips dev-dependency plugins from release and profile builds, and Dart tree-shaking removes the unreachable debug code.
Exclude the toolkit
Move it to dev_dependencies
Keep production code free of the package
No production-reachable file may import
carp_debug_flutter. Read launch arguments through a small app-local hook that has no dependency on the package:In release builds the hook is
null, so the--dart-definevalue is used and the package is never referenced.Isolate the toolkit wiring behind kDebugMode
Put all package usage in one debug-only file, and call it only when
kDebugModeis true:
Gate on kDebugMode, not kReleaseMode
Dev-dependency plugin natives are present only in debug builds. Gating on kDebugMode keeps the Dart usage aligned with native availability, so profile builds never hit a MissingPluginException.
What gets excluded per platform
| Platform (release and profile builds) | Dart code | Native plugin |
|---|---|---|
| Android | Tree-shaken out | Excluded from the plugin registrant and the build |
| iOS | Tree-shaken out | Still linked, but inert (see below) |
iOS and macOS
Flutter does not yet filter dev-dependency plugins out of the native build on iOS and macOS (flutter#163874). The toolkit's small native stub is still linked into the archive, but it is inert: the Dart code that would call it is tree-shaken away, so it never runs and exposes no behavior.