Dart Get Started
Install Dart and write your first program
🚀 Getting Started with Dart
Start your Dart programming journey by installing the Dart SDK and running your first program. Dart installation is simple and works on Windows, macOS, and Linux systems.
// Your first Dart program
void main() {
print('Hello, I am learning Dart!');
}
Output:
Hello, I am learning Dart!
Install Dart SDK
Windows
Install using Chocolatey or direct download
choco install dart-sdk
macOS
Install using Homebrew
brew tap dart-lang/dart
brew install dart
Linux
Install using apt package manager
sudo apt update
sudo apt install dart
Online
Try Dart without installation
Visit: dartpad.dev
🔹 Verify Installation
Check if Dart is installed correctly:
# Check Dart version
dart --version
# Expected output:
# Dart SDK version: 3.2.0 (stable)
Output:
Dart SDK version: 3.2.0 (stable)
🔹 Create Your First Dart File
Follow these steps to create and run your first Dart program:
Step-by-step guide:
-
Create a new file called
hello.dart - Write your Dart code in the file
- Save the file
-
Run the program using
dart hello.dart
// Save this as "hello.dart"
void main() {
print('Hello, World!');
print('This is my first Dart program');
print('Dart is easy to learn!');
}
Output:
Hello, World!
This is my first Dart program
Dart is easy to learn!
🔹 Run Dart Programs
Different ways to execute your Dart code:
🔸 Command Line
# Run a Dart file
dart hello.dart
# Run with arguments
dart hello.dart arg1 arg2
🔸 DartPad (Online)
// Try this code at dartpad.dev
void main() {
print('Running Dart online!');
// You can test code instantly
var name = 'DartPad User';
print('Welcome, $name');
}
Output:
Running Dart online!
Welcome, DartPad User
🔹 Recommended Code Editors
Best editors for Dart development:
🔸 Visual Studio Code (Recommended)
- Install the "Dart" extension
- Syntax highlighting and auto-completion
- Debugging support
- Integrated terminal
🔸 Android Studio / IntelliJ IDEA
- Install Dart and Flutter plugins
- Advanced debugging tools
- Built-in emulator support
🔸 Other Options
- Sublime Text with Dart package
- Vim with Dart plugin
- Any text editor (basic editing)
🔹 Practice Exercise
Try creating this simple program:
// Create a file called "practice.dart"
void main() {
// Print your name
print('My name is [Your Name]');
// Print your age
print('I am [Your Age] years old');
// Print a fun fact
print('Fun fact: I am learning Dart programming!');
}
Expected Output:
My name is John Doe
I am 25 years old
Fun fact: I am learning Dart programming!