How to create a Dart project manually

If you want to create a Dart project, probably the best way to do that currently is to use Stagehand:

Once you install that you can create new Dart command-line applications like this:

// create a command-line application
stagehand console-full

However, if you just want to create a little Dart project manually, you can also just follow the steps below:

Back to top

1. Create a project directory

mkdir my_app
Back to top

2. cd into that directory

cd my_app
Back to top

3. Create a pubspec.yaml configuration file

vi pubspec.yaml

Add some basic contents:

name: my_app
description: My app
version: 0.0.1
author: alvin

dependencies:
  test: ^1.6.0
Back to top

4. Get any dependencies you added

pub get
Back to top

5. Start coding your app

Put your Dart source code in a lib directory (or just in the main directory):

mkdir lib

vi lib/my_app.dart

Add source code:

void main() {
    print('hello, world');
}
Back to top

6. Run your Dart app

dart lib/my_app.dart
Back to top

More information

Depending on your needs, there are other Dart commands available:

dart
dart2aot
dart2js
dartanalyzer
dartaotruntime
dartdevc
dartdoc
dartfmt
Back to top

Summary

If you needed an example of how to manually create a Dart project, I hope this example is helpful.

Back to top