Dart Introduction
Dart is a modern programming language developed by Google, designed for building high-performance, cross-platform applications.
This chapter introduces you to Dart's origins, design philosophy, and its broad application scenarios in frontend, mobile, and backend development.

The History and Design Goals of Dart
Dart was born in 2011, with the initial goal of replacing JavaScript as the browser's native scripting language.
Although this goal was not achieved, Dart hit a critical turning point in 2017—the release of the Flutter framework brought Dart back into developers' view.
Dart's design goals are very clear:
| Design goals | Description |
|---|---|
| High Performance | Supports AOT (Ahead-of-Time) and JIT (Just-in-Time) compilation, enabling rapid development while generating native code. |
| Strong typing | Supports type inference, balancing type safety with development efficiency. |
| Cross-platform | A single codebase can be compiled to ARM, x64 machine code, or JavaScript. |
| Easy to learn | Syntax borrowed from mainstream languages such as Java, JavaScript, and C#, reducing the learning cost. |
| Null safety | Built-in Null Safety mechanism, avoiding 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.
Application Scenarios of Dart
Dart's application scenarios are very broad, covering full-stack development needs from mobile to backend.
Mobile Development (Flutter)
This is Dart's most core application scenario at present.
Through the Flutter framework, Dart can build native applications for both iOS and Android platforms, with a single codebase running on both.
Web Development
Dart can be compiled to JavaScript for building web frontend applications.
AngularDart is Google's maintained Dart version of the Angular framework, suitable for large-scale web projects.
Server-side development
With the dart:io library and frameworks such as Shelf, Dart can also be used to write high-performance server-side applications.
Multiple server-side projects inside Google are written in Dart.
Command-line tools
Dart can be compiled into standalone executable files, making it well-suited for writing cross-platform CLI tools.
| application scenarios | Compilation targets | Typical frameworks/tools |
|---|---|---|
| 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 Dimension | Dart | JavaScript |
|---|---|---|
| Type system | Strong typing, supports type inference | Weak typing, dynamic typing |
| Null safety | Built-in Null Safety | None (requires TypeScript or manual checking) |
| Entry function | Must have a main() function | Direct script execution |
| Classes and inheritance | Class-based OOP, single inheritance | Prototype chain-based |
| Compilation method | AOT + JIT dual mode | JIT-based |
| 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 will be very easy—their async syntax (async/await) is almost identical.
However, Dart's type system and null safety mechanism will give you a greater sense of security in large projects.
Example
A comparison of how the same functionality is written in the two languages:
function greet(name) {
if (name === null || name === undefined) {
return 'Hello, stranger!';
}
return `Hello, ${name}!`;
}
console.log(greet('example'));
console.log(greet(null));
String greet(String? name) {
// name may be null, needs explicit handling
if (name == null) {
return 'Hello, stranger!';
}
return 'Hello, $name!';
}
void main() {
print(greet('example'));
print(greet(null));
}
Hello, example! 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 compilationSupports Hot Reload—seeing results in sub-seconds after modifying code, greatly improving development efficiency.
- AOT compilationGenerates native machine code, apps start fast and run smoothly, without the performance overhead of a JavaScript Bridge
- Dart's declarative UINaturally fits with Flutter's Widget tree structure
- Unified technology stackGoogle maintains both the language and the framework simultaneously, ensuring good version compatibility.
Before learning Flutter, it is recommended to first master the basics of Dart. After understanding the language features, the learning curve for Flutter will be much smoother. This tutorial is prepared for this purpose.
A brief history of Dart version development
| Version | Release date | Important Features |
|---|---|---|
| Dart 1.0 | 2013 | First stable version, basic language features |
| Dart 2.0 | 2018 | Strong type system, with new/const being 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 versions, and all code examples have been verified on Dart 3.0 and above.
other extensions