Images are often the largest part of a Flutter app that you control directly. Dart code is tree-shaken and compiled, but bundled assets ship exactly as you commit them. A few oversized PNGs can add tens of megabytes to your download.
Step 1: Measure before you optimize
Flutter can break down what contributes to build size. Run the analyzer for the platform you ship:
flutter build apk --analyze-size
flutter build ios --analyze-sizeThe report lists assets alongside code, so you can see whether images are the problem before spending time on them.
Step 2: Remove what you do not need
- Delete unused images from the assets folder and from pubspec.yaml.
- Do not bundle 4K artwork for a 400 px slot. Export at the largest size the UI actually draws.
- Consider loading rarely used, large images from the network with caching instead of bundling them.
Step 3: Compress PNG and JPEG assets
Lossy PNG quantization and optimized JPEG encoding commonly cut file sizes substantially with little visible change, especially for screenshots, illustrations and AI-generated images. Results vary by image, so compare outputs on a real device before you commit them.
Step 4: Convert large images to WebP
Flutter supports WebP, and for photographic images WebP is usually smaller than PNG or JPEG at similar quality. A command-line example using cwebp:
cwebp -q 80 input.png -o output.webpKeep PNG where you need exact pixels, such as pixel-art sprites, and use SVG or vector assets for simple icons.
Step 5: Automate it
Manual compression gets forgotten. TinyPixels can watch your assets folder and compress new images the moment they land, locally and without a build plugin. See the Flutter assets guide for a setup walkthrough.
Privacy note
Compressing locally means unreleased app artwork never leaves your machine, which is not true of upload-based compressors.
Checklist
- Measure with --analyze-size.
- Delete unused and oversized assets.
- Compress PNG and JPEG.
- Convert photos to WebP where appropriate.
- Re-measure and test on a device.
Frequently asked questions
How do I check how much my images add to my Flutter app size?
Run flutter build apk --analyze-size or flutter build ios --analyze-size. The report breaks down code and assets so you can see the contribution of your images.
Does Flutter support WebP images?
Yes. WebP images can be bundled as assets and displayed with Image.asset, and they are often smaller than equivalent PNG or JPEG files.
Should I compress PNG assets in a Flutter app?
Yes, especially large screenshots and illustrations. Lossy PNG quantization and lossless optimization both reduce size; test results on a device before committing.
Can I automate image compression for Flutter projects?
Yes. A desktop tool like TinyPixels can watch your assets folder and compress new images automatically, with no build plugins.