Flutter apps are too big in size

Use following commands to analyze which is taking up most your app's space.

For Android's AppBundle:

flutter build appbundle --target-platform android-arm --analyze-size
flutter build appbundle --target-platform android-arm64 --analyze-size
flutter build appbundle --target-platform android-x64 --analyze-size

For Android's APK:

flutter build apk --target-platform android-arm --analyze-size
flutter build apk --target-platform android-arm64 --analyze-size
flutter build apk --target-platform android-x64 --analyze-size

For iOS:

flutter build ios --analyze-size

For Linux:

flutter build linux --analyze-size

For macOS

flutter build macos --analyze-size

For Windows

flutter build windows --analyze-size

This includes native code, assets, and even a package-level breakdown of compiled Dart code.


DevTools

If you want to see the visual representation of it, use DevTools. For that after running previous command, run:

flutter pub global run devtools --appSizeBase=apk-code-size-analysis_01.json

You'll be then directed to your browser, where you will see something like this:

enter image description here


Flutter team acknowledges it here.

There's an explanation for this here, quoting the same -

In August 2018, we measured the size of a minimal Flutter app (no Material Components, just a single Center widget, built with flutter build apk), bundled and compressed as a release APK, to be approximately 4.7MB.

For this simple app, the core engine is approximately 3.2MB (compressed), the framework + app code is approximately 840KB (compressed), the LICENSE file is 55KB (compressed), necessary Java code (classes.dex) is 57KB (compressed), and there is approximately 533KB of (compressed) ICU data.

Of course, YMMV, and we recommend that you measure your own app, by running flutter build apk and looking at build/app/outputs/apk/release/app-release.apk.

Also, the relative differences in apk size would likely be smaller with larger apps. Flutter's overhead size is fixed.


One way that i use to reduce my app size is to use;

flutter clean

before i run the build command;

flutter build appbundle --target-platform android-arm,android-arm64

When i run the build command without the clean command, i get around 32mb, but if i run the clean command first, i get around 18mb