How to reduce the size of an application made with flutter?
Removing Unused Resources
Deleting unused resources can be done in Manual Methods and Automatic Methods.
Manual methods can be done by deleting files that you don’t need.
Automatic methods can be done using Android Studio.
- Right Click on Project
- Click the Refactor Menu
- Click the Remove Unused Resources menu
Compress PNGs and JPGs
Do a quick google search for tools to compress your PNGs and JPGs.you should compress your PNGs and JPGs as those of high quality will bloat up the app size.
Doing Optimise Import
It doesn’t have much effect on the size of the app. But it is Good to maintain. The automatic method is by using Android Studio.
Right-click on the lib folder
Click Optimize Import
Once done building your app, you should check your
libraries/packageswhich are not used.
Delete unnecessary ones
Analyzing and optimizing the most extensive files and folders is quite effective.
To Test the release android app, run the following command on the terminal.
flutter build apk --split-per-abi
You will get three apk files from the
build/app/output/apk/release folder. You can test the v7 version of the apk file.
If you want to publish the app in the google play store, don’t upload any of the following files.
Use an app bundle file that Google recommends.
To generate an app bundle, run the following command on the terminal.
flutter build appbundle
After that, you will get an
.aab file in the
Now you can upload this
.aab file to the google play store.
The Best Habit uses a command like below.
flutter build appbundle --target-platform android-arm,android-arm64,android-x64