Mohammad AfsahOct. 23, 2025
App size isn’t just a number — it’s the first impression your users get.
A lighter Flutter app installs faster, loads quicker, and performs better on every device. Whether you’re optimizing an MVP or scaling a production app, every megabyte matters.
In this advanced guide, we’ll explore how to reduce your Flutter app intelligently using techniques like tree shaking, code size reduction, and bundle optimization — complete with real commands, tips, and best practices.
New to Flutter optimization?
Start with our beginner-friendly guide — How to Reduce Flutter App Size by 60%
Tree shaking is Flutter’s automatic process for removing unused Dart code during release builds. When you compile your app in release mode, the Dart compiler analyzes your codebase, keeps what’s needed, and discards everything else — dramatically cutting size.
This process happens automatically when you build with:
flutter build apk --release
💡 Pro Tip: Tree shaking only removes unused Dart code. Assets, fonts, and native libraries are handled separately — so don’t forget to optimize those too.
In rare cases, the compiler may keep extra code because it can’t be sure whether it’s needed. This happens if you:
Whenever possible, call functions and classes directly, not via strings or reflection, so Flutter can safely eliminate unused code.
Images are often the biggest contributors to app size.
Before adding them to your Flutter project:
Every package you add increases your binary size.
Audit your project regularly with:
flutter pub deps
Then remove unused or redundant packages.
Even small cleanup steps can save several megabytes — especially if plugins contain large native libraries.
Not every feature needs to load at startup.
With deferred loading, you can load parts of your app only when needed.
Example:
import 'settings_page.dart' deferred as settings;
Future<void> openSettings() async {
await settings.loadLibrary();
Navigator.push(context, MaterialPageRoute(builder: (_) => settings.SettingsPage()));
}
This approach keeps your initial app bundle smaller and loads additional code on demand.
⚠️ Test deferred loading carefully — it may not be ideal for every app or plugin.
Fonts can add several megabytes to your build.
Use system fonts whenever possible or subset your custom fonts to include only necessary characters.
Try Font Squirrel’s Webfont Generator to create optimized, subsetted fonts.
Instead of packaging every architecture in one APK, generate smaller APKs per ABI:
flutter build apk --split-per-abi --release
This reduces the app size by 30–40% per build.
Google Play now requires App Bundles (AAB) for publishing.
They automatically serve the right version for each device, eliminating unused resources.
Build with:
flutter build appbundle --release
App Bundles typically reduce download size by up to 50% compared to universal APKs.
For Android builds, enable code shrinking in android/app/build.gradle :
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
R8 removes unused Java/Kotlin classes from dependencies and compresses your native code further.
⚠️ Test thoroughly — aggressive ProGuard rules may strip classes required by Flutter plugins.
Obfuscation helps protect your Dart code and may reduce symbol size slightly:
flutter build apk --release --obfuscate --split-debug-info=./debug-info
Keep the debug-info folder safe — it’s required for symbolizing crash reports.
Find out exactly what’s making your app heavy:
flutter build apk --analyze-size --release
This command generates a JSON file you can open in Flutter DevTools.
You’ll see a detailed breakdown of:
Focus first on the largest items — often large plugins, images, or fonts.
Area |
Technique |
Expected Impact |
Images |
Convert PNGs → WebP |
20–70% smaller |
Dependencies |
Remove unused packages |
5–15% smaller |
Fonts |
Subset fonts |
1–5 MB smaller |
Native code |
Use R8/ProGuard |
5–10 MB smaller |
Build type |
Use --split-per-abi |
30–40% smaller per APK |
App Bundle |
Switch to AAB |
Up to 50% smaller downloads |
Optimization isn’t a one-time task — monitor app size each release.
# Build optimized release APK
flutter build apk --release
# Split by architecture (reduces file size)
flutter build apk --split-per-abi --release
# Build Android App Bundle (for Play Store)
flutter build appbundle --release
# Analyze build size breakdown
flutter build apk --analyze-size --release
# Obfuscate Dart code (optional)
flutter build apk --release --obfuscate --split-debug-info=./debug-info
Reducing Flutter app size isn’t just about making it lighter — it’s about delivering a smoother, faster user experience.
By combining tree shaking, bundle optimization, and smart asset management, you can reduce your app size by up to 60% without losing functionality.
Keep optimizing, measure every build, and make your Flutter app as fast and efficient as it looks.
0