DART : Why dart apps are so big in size? (console app) DART : Why dart apps are so big in size? (console app) dart dart

DART : Why dart apps are so big in size? (console app)


The reason for the big executable is because the dart2native compiler is not really made to make a executable you can directly run on your machine from scratch. Instead, it package the dartaotruntime executable together with your AOT compiled Dart program.

The dartaotruntime contains all the Dart runtime libraries and dart2native does not remove anything from the dartaotruntime (also difficult since it is a binary) so you will get the whole runtime even if you only adds two numbers.

But it is not that bad since it is an one-cost penalty for every program. So if you make a very big program, the dartaotruntime are still only include once.

However, if you are deploying many small programs in a single package I will recommend you add the -k aot parameter to dart2native so it instead of an executable will generate an .aot file which you then can run with dartaotruntime <program.aot>.

This will make your deployment a bit more complicated but you will just need to provide the dartaotruntime binary together with you multiple .aot files.

I have compiled your program to both .exe and .aot on Dart for Windows 64 bit. version 2.8.2 so you can see the size difference:

enter image description here

Again, -k aot will not save you any disk space if you are only going to deploy a single executable. But it can save a lot if your project contains many programs.

It should also be noted that the .aot file is platform dependent like the .exe file would be. And you should use the same version of dartaotruntime which has been used to compile the file.


It is because natively dart app are made by incorporate the render engine... I know that is right for all the flutter app which are based on dart.Look at this too https://medium.com/@rajesh.muthyala/app-size-in-flutter-5e56c464dea1