virtouso
virtouso

Reputation: 569

flutter build size is more than expected

As i searched in internet, an empty flutter build should be about 7.5 megabytes.

I build it in debug mode using command prompt windows flutter run its about 26 megabytes. Is there any settings or something else to make the final output optimized and less size?

Upvotes: 4

Views: 1289

Answers (2)

theapache64
theapache64

Reputation: 11754

From here

Debug

  • Compilation is optimized for fast development and run cycles (but not for execution speed, binary size, or deployment.)

Release

  • Compilation is optimized for fast startup, fast execution, and small package sizes.

In debug mode, the APK size will be higher compared to release mode. Because, in order to increase the development speed and run cycles, they do debug processes in the APK itself.

But in release mode, you'll get small package size as they will remove development packages from the APK.

Upvotes: 1

Rubens Melo
Rubens Melo

Reputation: 3305

From the docs:

By default, flutter run compiles to debug mode It means:

  • Assertions are enabled.
  • Observatory is enabled, allowing you to use the dart debugger.
  • Service extensions are enabled.
  • Compilation is optimized for fast development and run cycles (but not for execution speed, binary size, or deployment.)

You should use flutter run --release for deploying the app, when you want maximum optimization and minimal footprint size. It means:

  • Assertions are disabled.
  • Debugging information is stripped out.
  • Debugging is disabled.
  • Compilation is optimized for fast startup, fast execution, and small package sizes.
  • Service extensions are disabled.

Upvotes: 3

Related Questions