Create a new project
Use the dart create command to scaffold a new Dart project:
dart create myapp
cd myapp
This generates a project with:
pubspec.yaml— dependencies and metadatabin/main.dart— entry pointlib/— library codetest/— test files
Add dependencies
Edit pubspec.yaml or use the CLI:
# Add a package
dart pub add http
# Add a dev dependency
dart pub add --dev test
Then fetch:
dart pub get
Run
# Run the main entry point
dart run
# Or run a specific file
dart run bin/main.dart
Compile
# Compile to native executable
dart compile exe bin/main.dart
# Compile to JavaScript
dart compile js -o main.js lib/main.dart
Run tests
dart test