🎯 Dart — Engineering Reference

A code-first, production-grade Dart engineering reference. Each chapter is a deep-dive with annotated code blocks covering complex implementations, anti-patterns, edge cases, and performance optimizations. Designed for mid-level developers transitioning to senior roles who learn best through rigorous, real-world code.

How to Use This Reference

  1. Read sequentially for a complete engineering tour (01 → 19).
  2. Jump to a chapter as a reference when you hit a concept in production.
  3. Run the examples — dart run is your REPL, DartPad for quick experiments.
  4. Focus on the anti-pattern sections — each shows the naive code, the trap, and the production fix.

Prerequisites

  • The Dart SDK installed (brew install dart or see chapter 01).
  • A code editor (VS Code with the Dart extension recommended).
  • Solid programming fundamentals (this is not a beginner tutorial).

Curriculum

Part I — Language Architecture

#TopicWhy It Matters
01Architecture, Compilation & ToolchainAOT/JIT/kernel pipeline, platform conditionals, pubspec.yaml, native compilation.
02Variables, Type System & Memoryconst canonicalization, late lazy init, platform-dependent int, records.
03Operators, Promotion & ExpressionsNull-aware chains, type promotion rules, cascade mechanics, overflow.
04Control Flow, Exhaustiveness & PatternsDart 3 exhaustive switches, sealed patterns, record destructuring, guards.
05Functions, Closures & GeneratorsParameter semantics, closure capture, sync*/async*, callable classes.

Part II — Core Systems

#TopicWhy It Matters
06Collections, Iterables & AllocationLazy chain evaluation, spread/collection-if, immutable views vs copies.
07Classes, Sealed Hierarchies & MixinsConst canonicalization, sealed exhaustiveness, mixin linearization, factories.
08Sound Null Safety & Flow AnalysisPromotion rules (fields/closures/await), late semantics, nullable algebra.
09Async Internals, Futures & StreamsEvent loop, Future.wait composition, stream backpressure, zones.
10Isolates, Actor Model & Zero-CopyIsolate.run, worker pools, TransferableTypedData, when to use isolates.

Part III — Advanced Semantics

#TopicWhy It Matters
11Exceptions, Errors & Async PropagationException vs Error, rethrow stack preservation, runZonedGuarded, swallow traps.
12Reified Generics, Bounds & CovarianceRuntime type info, bounded params, covariance soundness, is T vs as T.
13Libraries, Visibility & PackagesLibrary-private _, conditional imports, barrel files, deferred loading.
14Testing, Mocking & Async PatternsMatcher composition, async test semantics, mocktail, parameterized tests.
15Web Compilation, JS Interop & Cross-Platformdart2js/DDC/Wasm, extension types, conditional imports, web limitations.

Part IV — Application & Production

#TopicWhy It Matters
16Flutter Widget Architecture & Lifecycleconst canonicalization, build purity, mounted after await, state management.
17Server Architecture, Middleware & Databaseshelf pipelines, dart_frog routing, streaming I/O, parameterized SQL, AOT deploy.
18Tooling, Code Generation & CI/CDStrict analysis, build_runner, freezed/json_serializable, CI pipeline.
19Production Projects & CapstoneCLI parser, stream pipeline, isolate image processor, full-stack capstone.

Learning Path Suggestions

If you're coming from JavaScript/TypeScript

Read 02–03 (type system is stricter, const/final/late differ). Read 08 (sound null safety — promotion rules differ from TS). Read 09 (async — Future/Stream like Promise/AsyncIterator but with backpressure). Read 07 (sealed classes, mixins). Read 16 (Flutter) if doing UI.

If you're coming from Java/C#/Kotlin

Read 02–03 (syntax is familiar, but var/final/const/null-safety differ). Read 05 (named params, required). Read 07 (sealed classes, mixins — Dart 3). Read 08 (null safety — ?/!/promotion). Read 12 (reified generics — unlike Java's erasure). Read 09 (async — Future/Stream like CompletableFuture/Flow).

If you're learning Dart for Flutter

Read 01–09 (core language). Skim 10 (isolates — rare in Flutter). Read 16 (Flutter widget lifecycle, build purity, mounted) closely. Read 18 (build_runner, freezed). Read 15 (web) if targeting Flutter Web.

If you're a senior Dart/Flutter engineer

Focus on 03 (promotion across closures/await/fields), 07 (sealed exhaustiveness, mixin linearization), 08 (promotion pitfalls), 09 (Future.wait composition, stream backpressure, zones), 10 (TransferableTypedData, worker pools), 12 (covariance soundness, is T vs as T), 17 (shelf middleware, streaming I/O, dart compile exe), 19 (production patterns, capstone).

Companion Resources

Tooling

bash
# Install the Dart SDK (macOS):
brew tap dart-lang/dart
brew install dart

# Verify:
dart --version

# VS Code with the Dart extension (Dart-Code.dart-code):
# - Code completion, refactoring, debugging
# - Hot reload (Flutter)
# - dart format on save
# - dart analyze diagnostics