New to Rust? Grab our free Rust for Beginners eBook Get it free →
Dart Getting Started Guide

To write a first Dart program, you can try it in a browser or run it from a file on your computer. Dart is a programming language used to build applications, and DartPad lets you try it in a browser.
I’ll show you how to try Dart in DartPad and run a local program with dart run.
TL;DR
Dart is the language used by Flutter, and you can learn its basics in DartPad or install the Dart SDK and run a local file with dart run.
- Use DartPad for a browser experiment.
- Install the Dart SDK for local command-line work.
- Begin with main(), then add variables, types and control flow.
What Is Dart?
Dart is a programming language maintained by Google and used to build applications. Flutter uses Dart for its app code, while the Dart SDK also supports command-line programs.
A Dart program starts at a top-level main() function. The SDK supplies tools to run and compile code, and its package tooling manages reusable libraries. Try syntax in DartPad before installing anything, then use the SDK when you need files and terminal execution.
How to Get Started with Dart Step by Step
DartPad gives you a browser-based way to try the language. I could not run Dart in this workspace because the executable is absent, so the examples follow official documentation and make no claim of local execution.
Step 1: Try Dart in DartPad
Open DartPad to edit a small Dart example in a browser. Use its run control to see the result. Interface details can change.
Step 2: Install the Dart SDK for local work
For terminal work, follow the official Dart SDK installation guide for your operating system, since distribution steps can change.
After installation, open a terminal in the folder you plan to use and check that the Dart executable is on your PATH before running a source file.
dart --version
The command reports the installed SDK version.
Step 3: Create a Dart program
Create hello.dart with a main() function. It is the entry point for this command-line example, and print writes a line to standard output.
void main() {
print('Hello, Dart!');
}
This source introduces the entry point and a function call. Check your file by running it with the SDK command in the next step.
Step 4: Run the file with dart run
Open a terminal in the directory containing hello.dart and run the Dart tool:
dart run hello.dart
The program prints Hello, Dart! Running it from the file’s directory avoids relative-path confusion. The official Dart command-line tool guide documents the runner.
Step 5: Add variables and a condition
Dart infers a local variable’s type from its initial value. Use var when the variable will be assigned again, final when it is assigned once at runtime, and const for a compile-time constant.
void main() {
final score = 12;
if (score >= 10) {
print('Continue');
} else {
print('Try again');
}
}
The condition selects a branch from a boolean expression. Dart infers that score is an integer without an explicit int annotation.
Dart Setup and Syntax Issues to Check
First-run problems often come from invoking the wrong file or misunderstanding whether a variable can change. Check the executable, working directory and type declaration before changing code.
| Symptom | What to check | Next step |
|---|---|---|
| Dart not found | SDK installation and PATH | Follow official setup for your OS, then open a new terminal. |
| File not found | Current directory and filename | Run from the folder containing the .dart file. |
| Assignment rejected | Whether the variable is final or const | Use var if reassignment is required. |
| Null value rejected | Whether the type is nullable | Use a nullable type only when null is valid. |
Dart’s sound null safety makes non-nullable types the default. Mark optional values with ? in the type, such as String?.
Conclusion: Keep the First Program Small
Build on the first example by adding variables and a condition. The Flutter REST API guide and Flutter state management guide show where Dart basics lead in Flutter projects.
For authoritative next steps, use the Dart tutorial and the language tour. They continue from the same fundamentals.
FAQ
These answers cover the first decisions when starting with Dart.
Can I learn Dart without installing it?
Yes. DartPad lets you experiment with Dart in a browser. Install the Dart SDK when you want to work with local files or command-line tools.
How do I run a Dart file?
Save the program in a .dart file, open a terminal in its directory, and run dart run filename.dart with the Dart SDK installed.
What does the question mark mean in a Dart type?
A question mark marks a nullable type, such as String?, which can hold either a string or null.




