How to Decrease Flutter App size in Android Platform?

· 6 min read
How to Decrease Flutter App size in Android Platform?
How to Decrease Flutter App size in Android Platform?

Several app developers consider the size of their compiled application. As an IPA version, the app bundle or the APK of an app is self-contained and grips all assets and code required to successfully run the app; its size is always a concern. Size becomes more vital when it is a larger app as you will need more space on a device.

The larger app also takes longer to download, and it may rift vital features like Android instant apps. It enlarges the Flutter app and can be two, three or more install sizes. Therefore, it is significant to decrease the size of the Flutter app on the Android platform.

Know the 8 best ways to decrease the size of the Flutter app:

1. Reduce App Element Size

When a user installs an application from Play Store, they get the loading bar after that the actual size of the app. There is a high chance of cancelled/failed download with the larger apps. As the best Flutter app development company, we should concise the app size as possible.

2. Compress all JPEG and PNG Files

You can reduce the size of all PNG and JPEG files; however, never lose image quality. You can use tools such as pngquant, zopflipng, or pngcrush. All these tools you can use to reduce image size without compromising its quality.

The pngcrush tool is effective as it iterates over zlib (Deflate) parameters and PNG filters utilizing each combination of parameters and filters to compress the image.

Moreover, to compress JPEG images, you can utilize other tools such as guetzli and packJPG.

3. Use Google Fonts

Fonts are a vital element in any website or app. Indeed, you require attractive and user-friendly fonts to attract users to your website. Therefore, you can utilize the google fonts package instead of bundling fonts in-app.

With this package, .otf or .ttf files are mapped in the pubspec.yaml file and will not get stored in your assets folder. Instead of this, you can fetch them via HTTP at runtime and easily cache them in the app file system.

4. Use the Analyzer in Android Studio

Use the plugin marketplace in Android Studio and download the Android Size Analyzer plugin from here. Check the process below to open and install the plugin:

  1. Select File > Settings (or on Mac, Android Studio > Preferences.)
  2. Go to the Plugins section shown in the left panel.
  3. Click on the Marketplace tab.
  4. Start your search for the “Android Size Analyzer” plugin.
  5. Now click on the Install button to get the analyzer plugin.

If you are facing issues in implementing the above process, it is recommended to connect with the best Flutter app development company as they can help in the best possible ways and bring the best solution to your desk.

After installing the plugin, run an app size analysis on your current project by selecting Analyze > Analyze App Size from the menu bar. After analyzing your project, a tool window appears with recommendations on reducing the size of your app.

5. Use the Analyzer From the Command Line

From GitHub, You can also download the latest version of Android Size Analyzer as a Zip or TAR file. Now extract the zip file and run the size-analyzer.bat script on Windows or run the size-analyzer script on MacOS or Linux on Android App Bundle utilizing the below commands:

./size-analyzer check-project ./size-analyzer check-bundle

6. Reduce resource count and size

The size of your APK impacts the app’s speed, how much power it uses, how much memory it utilizes. One of the best ways to reduce the size of your APK is to minimize the size and number of resources it holds.

Specifically, you can eradicate resources that are no longer in use and utilize scalable Drawable objects instead of images.

7. Evade Enumerations

Even a single enum can enumerate 1.0 to 1.4 KB size to classes.dex file of the app. These conditions can easily be compiled for shared libraries or complex systems. You can also consider using the code shrinking and @IntDep annotation to scale enumerations out and convert these enumerations to integers.

8. Use Vector Graphics

Vector graphics is one of the best ways to reduce Flutter app size in Android. Use vector graphics to develop resolution-independent icons and other scalable media. Using these graphics lets you decrease your APK footprint.

In Android, vector images are shown as VectorDrawable objects. Just a 100-byte file can easily create a clear and sharp image on the screen.

However, it requires significant time to render each VectorDrawable object; also, larger image files take more time to appear on the screen. So, if you want to display a small image, then utilize these vector graphics.

Takeaway

The size of an app is always important; it is vital for its performance. Except for the above-mentioned methods, you should also optimize your code to reduce the app’s size. There are several coding practices, and creating a sustainable architecture will enable the app to perform smoothly.

Leave a Reply