Introduction to Dart
Dart is a modern programming language developed by Google, designed for building high-performance, cross-platform applications.
This chapter introduces Dart's origins, design philosophy, and its wide range of application scenarios on the front end, mobile, and server side.

The History and Design Goals of Dart
Dart was born in 2011, with the original goal of replacing JavaScript as the native scripting language of the browser.
Although that goal was not achieved, Dart reached a key turning point in 2017 -- the release of the Flutter framework brought Dart back into developers' view.
Dart's design goals are very clear:
| Design Goal | Description |
|---|---|
| High performance | Supports AOT (ahead-of-time compilation) and JIT (just-in-time compilation), enabling both fast development and native code generation |
| Strong typing | Supports type inference, balancing type safety and development efficiency |
| Cross-platform | One codebase can be compiled to ARM, x64 machine code, or JavaScript |
| Easy to learn | The syntax draws on mainstream languages such as Java, JavaScript, and C#, lowering the learning cost |
| Null-safe | Built-in Null Safety mechanism avoids null pointer exceptions at the language level |
Dart 2.0 was released in 2018, marking the language's maturity. Dart 3.0 was released in 2023, further strengthening features such as the type system and pattern matching.
Dart's Application Scenarios
Dart's application scenarios are very broad, covering full-stack development needs from mobile to server side.
Mobile Development (Flutter)
This is currently Dart's most core application scenario.
Through the Flutter framework, Dart can build native apps for both iOS and Android platforms, running one codebase on both.
Web Development
Dart can be compiled to JavaScript for building Web front-end applications.
AngularDart is the Dart version of the Angular framework maintained by Google, suitable for large Web projects.
Server-Side Development
Through the dart:io library and frameworks like Shelf, Dart can also write high-performance server-side applications.
Google has multiple internal server-side projects written in Dart.
command line tool
Dart can be compiled into standalone executables, making it very suitable for writing cross-platform CLI tools.
| Application scenarios | Compilation Target | Typical Framework/Tool |
|---|---|---|
| Mobile | ARM machine code | Flutter |
| Web front end | JavaScript | AngularDart |
| Server side | Machine code / JIT | Shelf, Dart Frog |
| Command line | Machine code | dart compile exe |
Dart vs JavaScript
Both Dart and JavaScript are object-oriented languages, but Dart is more rigorous in language design.
Below is a comparison of their differences across several dimensions:
| Comparison Dimensions | Dart | JavaScript |
|---|---|---|
| Type system | Strongly typed, supports type inference | Weakly typed, dynamically typed |
| Null-safe | Built-in Null Safety | None (requires TypeScript or manual checks) |
| Entry function | Must have a main() function | Scripts execute directly |
| Classes and inheritance | Class-based OOP, single inheritance | Based on the prototype chain |
| Compilation method | AOT + JIT dual mode | JIT mainly |
| Concurrency model | Isolate (message passing) | Worker threads / event loop |
| Package Management | pub.dev (unified official repository) | npm (community repository) |
If you have a JavaScript background, learning Dart is very easy -- their asynchronous syntax (async/await) is almost identical.
But Dart's type system and null safety mechanism will give you more confidence in large projects.
Example
A comparison of how the same functionality is written in the two languages:
// JavaScript version
function
greet
(
name
)
{
if
(
name
===
null
||
name
===
undefined
)
{
return
'Hello, stranger!'
;
}
return
`Hello
,
$
{
name
}
!
`
;
}
console.
log
(
greet
(
'runoob'
)
)
;
console.
log
(
greet
(
null
)
)
;
// Dart version -- null safety makes types clearer
String greet
(
String
?
name
)
{
// name may be null and needs explicit handling
if
(
name
==
null
)
{
return
'Hello, stranger!'
;
}
return
'Hello, $name!'
;
}
void
main
(
)
{
(
greet
(
'runoob'
)
)
;
(
greet
(
null
)
)
;
}
Hello, runoob!
Hello, stranger!
The Relationship Between Dart and Flutter
Many people first encounter Dart because of Flutter.
In fact, Flutter is Dart's "killer app", but Dart itself is an independent, general-purpose programming language.
The reasons Flutter chose Dart are as follows:
- JIT compilation supports Hot Reload, letting you see the effect in sub-second time after modifying code, greatly improving development efficiency
- AOT compilation generates native machine code, so apps start fast and run smoothly, without the performance overhead of a JavaScript Bridge
- Dart's declarative UI naturally fits Flutter's Widget tree structure
- Unified tech stack: Google maintains both the language and the framework, so version compatibility is good
Before learning Flutter, it is recommended to first master the basics of Dart. Once you understand the language features, Flutter's learning curve becomes much smoother. This tutorial is prepared for exactly that goal.
A Brief History of Dart Versions
| Version | Release date | Key Features |
|---|---|---|
| Dart 1.0 | 2013 | First stable release, basic language features |
| Dart 2.0 | 2018 | Strong type system, new/const optional |
| Dart 2.12 | 2021 | Introduced Null Safety |
| Dart 3.0 | 2023 | Pattern matching, Records, class modifiers |
This tutorial is written based on Dart 3.x, and all code examples have been verified on Dart 3.0 and above.