Dart
Overview
Dart is an approachable, portable, and productive language for building high-quality apps on any platform; it is the language behind the Flutter UI toolkit. It is strongly typed with sound null safety and compiles to native machine code (mobile/desktop/backend) or to JavaScript and WebAssembly for the web. Read this when writing Dart, building Flutter apps, or setting up the SDK.
Official sources
Install / setup
From the official Get Dart page. macOS via Homebrew, verbatim:
brew tap dart-lang/dart
brew install dart
Windows via Chocolatey, verbatim from the same page:
choco install dart-sdk
Source: https://dart.dev/get-dart (note: the Flutter SDK already includes the full Dart SDK)
Core concepts
- Sound null safety — types are non-nullable by default; nullable types use
?, and the compiler guarantees non-null values are never null at runtime.
- Strong static typing with inference —
var/final/const plus full type inference; dynamic opts out when needed.
- Everything is an object — including numbers and functions; functions are first-class values.
- Async with Futures and Streams —
async/await, Future<T>, and Stream<T> model single and multiple asynchronous results.
- Isolates — concurrency via isolated memory units that communicate by message passing (no shared mutable state).
- AOT and JIT compilation — JIT with hot reload during development, ahead-of-time native or JS/Wasm for release.
Best practices
- Follow Effective Dart (the official style/usage/design guide on dart.dev) for idiomatic code.
- Embrace sound null safety: prefer non-nullable types and handle nullability explicitly rather than reaching for
!.
- Use
final/const for values that don't change; mark compile-time constants const.
- Use the Dart SDK tooling (
dart analyze, dart format, dart test) and pub for packages.
Common pitfalls
- Overusing the null-assertion operator
! → throws if the value is null at runtime; prefer null-aware operators (?., ??) and proper null checks.
- Assuming shared mutable state across isolates → isolates do not share memory; pass data via messages.
- Forgetting to
await a Future → the code continues before the async work completes, causing race conditions.
Examples
class Greeter {
final String prefix;
const Greeter(this.prefix);
String greet(String? name) =>
'$prefix, ${(name == null || name.isEmpty) ? 'world' : name}';
}
void main() {
const g = Greeter('Hello');
for (final n in ['ada', 'grace']) {
print(g.greet(n));
}
}
Further reading
Related skills
- ../swift — another client-optimized, null-safe app language
- ../../stacks — Flutter and Dart web frameworks build on this language
1---2name: dart3description: Client-optimized, strongly typed language for building apps on any platform (powers Flutter); consult for syntax and setup.4domain: language5category: language6tags: [dart, flutter, client, cross-platform, null-safety]7official_sources:8 - https://dart.dev/guides9 - https://github.com/dart-lang/sdk10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/dart13---1415# Dart1617## Overview18Dart is an approachable, portable, and productive language for building high-quality apps on any platform; it is the language behind the Flutter UI toolkit. It is strongly typed with sound null safety and compiles to native machine code (mobile/desktop/backend) or to JavaScript and WebAssembly for the web. Read this when writing Dart, building Flutter apps, or setting up the SDK.1920## Official sources21- Docs: https://dart.dev/guides22- Repo: https://github.com/dart-lang/sdk23- Install / download: https://dart.dev/get-dart2425## Install / setup26From the official Get Dart page. macOS via Homebrew, verbatim:2728```bash29brew tap dart-lang/dart30brew install dart31```3233Windows via Chocolatey, verbatim from the same page:3435```powershell36choco install dart-sdk37```3839Source: https://dart.dev/get-dart (note: the Flutter SDK already includes the full Dart SDK)4041## Core concepts42- Sound null safety — types are non-nullable by default; nullable types use `?`, and the compiler guarantees non-null values are never null at runtime.43- Strong static typing with inference — `var`/`final`/`const` plus full type inference; `dynamic` opts out when needed.44- Everything is an object — including numbers and functions; functions are first-class values.45- Async with Futures and Streams — `async`/`await`, `Future<T>`, and `Stream<T>` model single and multiple asynchronous results.46- Isolates — concurrency via isolated memory units that communicate by message passing (no shared mutable state).47- AOT and JIT compilation — JIT with hot reload during development, ahead-of-time native or JS/Wasm for release.4849## Best practices50- Follow Effective Dart (the official style/usage/design guide on dart.dev) for idiomatic code.51- Embrace sound null safety: prefer non-nullable types and handle nullability explicitly rather than reaching for `!`.52- Use `final`/`const` for values that don't change; mark compile-time constants `const`.53- Use the Dart SDK tooling (`dart analyze`, `dart format`, `dart test`) and pub for packages.5455## Common pitfalls56- Overusing the null-assertion operator `!` → throws if the value is null at runtime; prefer null-aware operators (`?.`, `??`) and proper null checks.57- Assuming shared mutable state across isolates → isolates do not share memory; pass data via messages.58- Forgetting to `await` a `Future` → the code continues before the async work completes, causing race conditions.5960## Examples61```dart62class Greeter {63 final String prefix;64 const Greeter(this.prefix);6566 String greet(String? name) =>67 '$prefix, ${(name == null || name.isEmpty) ? 'world' : name}';68}6970void main() {71 const g = Greeter('Hello');72 for (final n in ['ada', 'grace']) {73 print(g.greet(n));74 }75}76```7778## Further reading79- Language and library guides: https://dart.dev/guides80- Effective Dart: https://dart.dev/guides (Effective Dart section)8182## Related skills83- ../swift — another client-optimized, null-safe app language84- ../../stacks — Flutter and Dart web frameworks build on this language