Wire the toolkit into your app so it works in debug builds and is excluded from release builds.
Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor
To keep the toolkit out of production archives, set up three parts: a launch-argument hook, a debug-only setup file and a kDebugMode gate in main(). This page assumes you have installed the package as a dev dependency.
Create a launch-argument hook
Create a file with no dependency on carp_debug_flutter. Production code reads launch arguments through this hook, so it never imports the package.
Read configuration through the hook anywhere in your app. In release builds the hook is null, so the compile-time value is used:
final mode = debugLaunchOverride?.call('deployment-mode') ?? const String.fromEnvironment('deployment-mode', defaultValue: 'production');
Create a debug-only setup file
This is the only file that imports the package. The two variants differ only in where the preferences and the database come from. myEnvEntries is defined in Define your launch arguments.
main() imports only the app-local debug_setup.dart and calls it only when kDebugMode is true. In release builds this folds to runApp(app), and the whole debug subtree, including the package, is tree-shaken away.
import 'package:flutter/foundation.dart';import 'debug/debug_setup.dart' as debug;Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); // Load overrides BEFORE the app reads its configuration. if (kDebugMode) await debug.initDebugTools(); final db = await openAppDatabase(); final app = await buildApp(db); runApp(kDebugMode ? debug.wrapWithToolkit(app, db) : app);}
Production builds explains why this excludes the toolkit from release archives and how to verify it.