Lumenary CS · Programming languages
Dart
The language behind Flutter: sound null safety, records and patterns, sealed classes, async code and isolates, from a first program to a finished project.
Dart is a general-purpose, garbage-collected language that Google announced in 2011. It is best known as the language of Flutter, the toolkit used to build apps for Android, iOS, the web and desktop from one codebase, but it is also a capable language on its own for command-line tools and servers. Dart compiles ahead of time to native machine code, to JavaScript and to WebAssembly, and runs on a fast virtual machine with hot reload during development. Its type system is sound, and since Dart 3 every program is null safe.
This course is for anyone who knows what a variable, a loop and a function are, for example from the Start level of Lumenary CS or equivalent experience. It covers the language itself rather than Flutter: variables and sound null safety, control flow and functions, collections, classes, mixins and extensions, the records, patterns and sealed classes of Dart 3, futures, streams and isolates, and the tools professionals use for packages, analysis and testing. Flutter's widget model is described in the last lesson, which ends with a complete project.
To run the code, install the Dart SDK from dart.dev/get-dart (the Flutter SDK includes it too), or paste any program into DartPad, the official online playground, which runs Dart in your browser. Every complete program in these lessons was run with dart run on Dart 3.14, and its output is shown exactly as it printed.
- Chloe · The Designer
“Why is the language built this way?” - Margaret · The Profiler
“What does it print, and what does it cost?” - Gideon · The Language Lawyer
“What exactly does the language guarantee?”
Foundations · 3 lessons
The core language
Install the SDK, meet Dart and Flutter, and learn variables, types, sound null safety, control flow, functions and exceptions.
- 1Dart and Flutter, first stepsWhere Dart came from, why Flutter chose it, how to install it, and your first programs. 45 min
- 2Variables, types and null safetyvar, final, const and late; numbers and strings; and a type system in which null can only go where you allow it. 50 min
- 3Control flow, functions and exceptionsBranches and loops, functions with named and optional parameters, closures, and what to do when things go wrong. 55 min
Practice · 3 lessons
Modelling data
Lists, sets and maps with collection literals; classes, constructors, mixins and extensions; and Dart 3's records, patterns and sealed classes with exhaustive switching.
- 4Collections and genericsLists, sets and maps; collection literals with if, for, spreads and null-aware elements; lazy iterables; and generic code. 55 min
- 5Classes, mixins and extensionsConstructors of every kind, value equality, inheritance and interfaces, mixins, class modifiers, and adding methods to types you did not write. 60 min
- 6Records, patterns and sealed classesDart 3's tools for data: anonymous records, patterns that test and take apart values, enhanced enums, and sealed families checked for exhaustiveness. 60 min
Professional · 2 lessons
Dart as professionals write it
Futures, async/await, streams and isolates; packages from pub.dev, the analyzer, the formatter and tests; Flutter's widget model; and a complete project.
- 7Futures, streams and isolatesHow one thread stays responsive with an event loop, async and await, streams of events, and isolates for real parallelism. 65 min
- 8Packages, tests, Flutter and a projectHow professional Dart is organized, analyzed and tested, how Flutter builds interfaces from widgets, and a complete program that uses the whole course. 75 min
Further reading and resources
- dart.devThe official site: language guide, library tour, tools and Effective Dart.
- Get the Dart SDKOfficial installers and package-manager instructions for Windows, macOS and Linux.
- DartPadThe official online playground for Dart and Flutter.
- Dart language specificationThe formal specification, and the proposals for newer features.
- Language evolutionWhat changed in each Dart release, with dates.
- Dart API referenceDocumentation for dart:core, dart:async, dart:collection and the other core libraries.
- pub.devThe package repository for Dart and Flutter.