Skip to content

Latest commit

 

History

History
 
 

native_app

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Native compilation sample

This sample is a command line application that can be compiled to native code using the dart2native command included in Dart 2.6.

Building and running an executable

To create a standalone executable, run the dart2native command on a Dart file with a main() function. By default, it places the executable in the same directory. The --output or -o flag is used to change the location of the executable.

Linux and macOS

To build the executable:

dart compile exe bin/main.dart -o hello_world

To run:

./hello_world

Windows

To build the executable:

dart compile exe bin\main.dart -o hello_world.exe

To run:

hello_world.exe

Building an AOT snapshot

The --output-kind or -k flag can be used to create an AOT snapshot:

dart compile aot-snapshot bin/main.dart -o hello_world.aot

This AOT snapshot can be run using the dartaotruntime command:

dartaotruntime hello_world.aot