Language basics
27 steps in 9 sets of Dart.
Dart is the language of Flutter, and therefore of a huge share of the cross-platform apps shipping today: one Google-built language that compiles to native ARM and x64, to JavaScript, and to WebAssembly, with hot reload making the edit-run loop feel like a scripting language. It started life in 2011 as a would-be JavaScript replacement, found its calling when Flutter arrived, and grew into a thoroughly modern language: sound null safety since 2021, and records, patterns, and sealed classes since Dart 3.
This tour types the core: var, final and const, string interpolation, switch expressions with relational patterns, named parameters with required and defaults, closures, extension methods, the three collection literals with spread and collection-if, iterable chains, classes with named constructors, mixins, enhanced enums, the null-safety toolkit, records and destructuring, sealed hierarchies, and async from Futures through Streams to sync* generators. The Encore is the cross-language script trio — word frequencies, a grade report, and temperature stats — in idiomatic Dart 3.
Values
- The program shapeThe smallest Dart program: main, print, and a template string.
- var, final and constThree ways to bind: mutable, once at run time, fixed at compile time.
- String interpolationTemplates with $, expression braces, and multiline literals.
Control flow
- if, else and the ternaryStatements branch with if; the ternary picks a value inline.
- switch expressionsDart 3's switch yields a value, with relational patterns and _.
- Loopsfor-in for collections, classic for for counting, while for guards.
Functions
- Named parametersBraces make parameters named; required and defaults do the rest.
- ClosuresFunctions are values that remember the variables around them.
- Extension methodsAdd members to types you do not own.
Collections
- Lists, sets and mapsThe three core collections, each with its own literal.
- Iterable chainswhere, map and fold read left to right; toList realizes them.
- Collection if and spreadBuild collections declaratively, right in the literal.
Classes
- Classes and constructorsthis. sugar assigns fields; named constructors add doors.
- MixinsBehavior stapled onto a class with with, no superclass claimed.
- Enhanced enumsDart enums are classes: fields, constructors, members.
Null safety
- Nullable typesString? admits null; the compiler tracks which one you hold.
- Null-aware operators??=, ?? and ! — the rest of the null toolkit.
- late and lazyDefer initialization without going nullable.
Records & patterns
- RecordsBundle values without a class; the shape is the type.
- PatternsDestructure and test in one motion, with guards.
- Sealed classesA closed hierarchy the compiler checks exhaustively.
Async
- Futures and async/awaitasync marks the function; await pauses it, not the program.
- Streams and async*A generator that emits over time; await for consumes in order.
- sync* generatorsLazy Iterables: nothing runs until something pulls.
Encore
- word_freq.dartA word-frequency table from split, map.update, and a two-key sort.
- grade_report.dartReport cards from a const roster, a switch expression, and padding.
- temp_stats.dartA week of temperatures: extremes, mean, a bar chart, and swings.