Low Orbit Flux Logo 2 F

Dart - Getting Started

Add some repos:

sudo apt-get install apt-transport-https
sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
sudo apt install curl
sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

Install Dart:

sudo apt-get update
sudo apt-get install dart

Creaste a project:

dart create -t console-full cli

Run it to test it out ( uses the Dart VM ):

cd cli
dart run

Edit the library and main program:

vi lib/cli.dart 
vi bin/cli.dart 

Run it again with your changes:

dart run

Compile it to a binary:

dart compile exe bin/cli.dart 

Note the ‘.exe’ extension even on Linux.

Run the binary:

./bin/cli.exe 

Compare running the binary to running it on the Dart VM:

time ./bin/cli.exe 
time dart run

Structure of the created project:

cli
cli/.dart_tool
cli/.dart_tool/package_config.json
cli/pubspec.yaml
cli/pubspec.lock
cli/test
cli/test/cli_test.dart
cli/bin
cli/bin/cli.exe                   #=== added after compile
cli/bin/cli.dart
cli/.packages
cli/CHANGELOG.md
cli/lib
cli/lib/cli.dart
cli/.gitignore
cli/README.md
cli/analysis_options.yaml

References