Dart Development Environment Setup
The first step in learning any programming language is to set up a working development environment locally.
This chapter will guide you through installing the Dart SDK, configuring an editor, and running your first Dart program.
Try It Online
If you just want to quickly try Dart without installing anything locally,DartPad is the most hassle-free choice.
DartPad is an online editor officially provided by Dart; no registration is needed -- just open your browser to write and run code.
Address accessed:https://dartpad.dev

Main Features of DartPad
- Write and run Dart code online and view output in real time
- Comes with several sample programs, ideal for getting started quickly
- Supports sharing code links, making collaboration and asking questions easier
- Supports Flutter code preview (you can run simple Flutter UIs in the browser)
Install the Dart SDK
The Dart SDK contains all the tools needed to compile, run, and debug Dart programs.
Choose the installation method that matches your operating system.
macOS Installation
If you use macOS, installing via Homebrew is recommended:
$ brew tap dart-lang/dart
$ brew install dart
After installation, verify the version:
$ dart --version
Dart SDK version: 3.5.0 (stable)
Windows Installation
Windows users can install via the Chocolatey package manager:
C:\> choco install dart-sdk
Or simply visit dart.dev/get-dart to download the installer and double-click it to run the setup wizard.
Linux Installation
On Debian/Ubuntu systems you can install via apt:
$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
$ echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
$ sudo apt-get update
$ sudo apt-get install dart
Verify the installation
Regardless of the system, after installation you can confirm the SDK works with the following command:
$ dart --version
$ dart --help
If you can see the version number and help information, the installation succeeded.
Using the DartPad Online Editor
If you do not want to install any software for now, DartPad is the fastest way to get started.
DartPad is an online Dart editor officially provided by Google; no registration is needed, just open and use it.
Access address:https://dartpad.dev
Features of DartPad:
| Feature | Description |
|---|---|
| Zero configuration | Open your browser to write and run Dart code |
| Supports Flutter | You can switch to Flutter mode and write examples with a UI |
| Code sharing | Generate a link to share your code snippets |
| Syntax highlighting | Built-in Dart syntax highlighting and code completion |
| Selectable versions | Supports choosing different Dart/Flutter versions |
DartPad is great for quickly verifying syntax and sharing code snippets. But for full project development, it is still recommended to configure a local IDE environment.
Configure VS Code
VS Code is currently the most popular editor for Dart development; with the official plugin it delivers an excellent development experience.
Installation Steps
Step one, make sure VS Code is installed (you can get it from code.visualstudio.com and download it).
Step two, open VS Code and go to the Extensions marketplace (shortcut Cmd+Shift+X or Ctrl+Shift+X).
Step three, search for and install the Dart extension (published by Dart Code).

Installing the Dart extension also automatically installs the Flutter extension (if a Flutter SDK is detected). If you plan to learn Flutter later, it is recommended to install the Flutter extension as well.
Verify the Configuration
After installation, create a new file in VS Code and name it hello.dart.
Enter the following code; if you see syntax highlighting and code hints, the configuration succeeded.
Example
void
main
(
)
{
(
'Hello, RUNOOB!'
)
;
}
Run the Code
There are three ways to run Dart code in VS Code:
| Method | Operation |
|---|---|
| Right-click menu | Right-click in the editor -> Run Without Debugging |
| Keyboard shortcut | Ctrl+F5(Windows) or Cmd+F5 (Mac) |
| Terminal command | Open the terminal and enter dart run hello.dart |
$ dart run hello.dart
Hello, RUNOOB!
Other IDE Options
| IDE | Plugin Name | Applicable scenarios |
|---|---|---|
| IntelliJ IDEA | Dart Plugin | The top choice for Java/Kotlin developers |
| Android Studio | Built-in support | Flutter mobile development |
| VS Code | Dart Extension | General development, lightweight and fast |
A First Look at Dart Project Structure
Besides running single files, Dart also supports a standardized project structure.
The dart create command quickly creates a Dart project skeleton:
$ dart create my_first_app
The generated directory structure is as follows:
my_first_app/
├── bin/
│ └── my_first_app.dart # 程序入口文件
├── lib/
│ └── my_first_app.dart # 库代码(可复用)
├── test/
│ └── my_first_app_test.dart # 测试文件
├── pubspec.yaml # 项目配置文件(依赖管理)
├── analysis_options.yaml # 静态分析规则
└── README.md
Description of each directory's purpose:
| Directory/File | Purpose |
|---|---|
| bin/ | Stores the entry-point files of executable programs |
| lib/ | Stores library code that can be referenced by other projects |
| test/ | Stores unit test files |
| pubspec.yaml | The project's metadata and dependency declarations |
| analysis_options.yaml | Configures static analysis rules for the code |
Enter the project directory and run the project:
$ cd my_first_app
$ dart run
Hello world: my_first_app!
For the basic-syntax learning stage, we mainly use single-file mode. When you start writing your own small projects, then use dart create to create a standard project structure.