<p dir="auto">Hey there -- I have a plugin (<a href="https://github.com/brianegan/flutter_stetho">flutter_stetho</a>) that should be used only during development for inspecting Network requests and Databases for Flutter apps.</p>
<p dir="auto">I ask users to use a <code class="notranslate">main.dart</code> and <code class="notranslate">main_dev.dart</code> so they can instantiate the code only during their dev process, and to include the plugin only in the <code class="notranslate">dev_dependencies</code> section in the <code class="notranslate">pubspec.yaml</code> file.</p>
<p dir="auto">However, if you build the app in production mode using the <code class="notranslate">main.dart</code> entry point, I believe the Dart code will be properly removed / tree shaken, but the Android plugin code is still being shipped. That makes the app size larger, and potentially makes Stetho a security risk (might accidentally allow users to inspect the Database or network requests)</p>
<p dir="auto">Is there a way for plugin authors to indicate to Flutter: "Hey, only include this Android/iOS for Dev builds, but not for production builds"?</p>
<p dir="auto">Also, more of a General Question: I was a bit confused as to why <code class="notranslate">dev_dependencies</code> are being included in Production builds at all. Is this by design? If so, could you describe why / when those are included?</p>
<h2 dir="auto">Use case</h2>
<p dir="auto">I'm maintaining a package providing bindings to sqlite via <code class="notranslate">dart:ffi</code>. For Android apps, we need to compile sqlite3 as a dynamic library that gets put into the apk. For iOS and non-Flutter Dart apps, we use the sqlite3 library from the system, if available.</p>
<p dir="auto">Since <code class="notranslate">dart:ffi</code> is still in an early stage, many users want to use native bindings for tests only, and use another package like <code class="notranslate">sqflite</code> for production. Unit tests are run on a desktop machine, so we don't compile any native libraries and instead use the one from the system. Unfortunately, the Flutter tool will include the native build script even if the package is just a <code class="notranslate">dev_dependency</code>. This means that native libraries are added into the built apk for no reason, but are still increasing app size.</p>
<h2 dir="auto">Proposal</h2>
<p dir="auto">The <code class="notranslate">dev_dependecies</code> section of a pubspec indicates that a package is only used for development. So, I believe that the Flutter tool should not view packages in <code class="notranslate">dev_dependencies</code> as a native package and not run their native buildscripts when using <code class="notranslate">flutter run</code> or <code class="notranslate">flutter build</code>.</p>