Different Options to Compile Dart Program

1. aot-snapshot

AOT stands for Ahead of time. This AOT module is used when we are deploying the command-line application, while deploying the application, the size should be minimal as compared to the local machine size. So to reduce the disk space AOT module is used. The art-snapshot subcommand is used to produce an output file specific to the system where we compile our application file. It means that the output file depends on the architecture of the system. If you are using Linux to compile file the .aot file is strictly specific to Linux only and for other Operating System also.

Command:

dart compile aot-snapshot geeks.dart

2. exe

The exe sub command generates the .exe file which is a standalone executable for Windows, macOS, and Linux distros. That generative .exe contains native machine code which is only understandable to the specific machine where it is compiled. If we compiled a dart file using dart compile exe geeks.dart on Linux then it only works on Linux and not on Windows and macOS. The output file generated by it (geeks.exe) has a small Dart runtime which is responsible for handling type checking and garbage collection.

Command:

dart compile exe geeks.dart

3. jit-snapshot

The jit-snapshot option for running the dart program is the default option, whenever we do not give any option it will run on this option only. The file extension is .jit of the generated file. The performance of JIT is faster than AOT (ahead of time) module.

Command:

dart compile jit-snapshot geeks.dart

4. js

To support the web, dart converts its program into javascript, and for that if we want explicitly JavaScript code then better to go for this option. The following three files are generated out.js, out.js.deps, and out.js.map which are the dependent files for out.js. These files are responsible for supporting the dart to the web environment.

Command:

dart compile js geeks.dart

5. kernel

kernel option generates a .dill file which is a binary file. This module will run on any platform that has Dart runtime installed. This option is helpful for the deployment of the application because its size is smaller than the actual size of the project and it is faster to execute. The generated file extension is *.dill and here * will be replaced by our source file name.

Command:

dart compile kernel geeks.dart

Compiling Dart Program using multiple options

Dart programming language is owned by Google and it is widely used for web development, desktop apps, and Android apps in the form of Flutter tool which is also owned by Google. Flutter is the cross-platform framework of Dart, which means Flutter can run its code on multiple platforms so that’s why it need different code for different platform. To achieve this requirement Google had a language named Dart which runs on multiple platforms but to do it we need a different compilation of the Dart program. So in this article, we are doing it for multiple platforms using the dart compile command for different platforms.

Similar Reads

Steps to Create Dart Program

Follow the below-specified steps to create the Dart Program:...

Different Options to Compile Dart Program

...

Conclusion

1. aot-snapshot...

Contact Us