This sample is a command line application that can be compiled to native code
using the dart2native
command included in Dart 2.6.
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.
To build the executable:
dart compile exe bin/main.dart -o hello_world
To run:
./hello_world
To build the executable:
dart compile exe bin\main.dart -o hello_world.exe
To run:
hello_world.exe
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