Learn Dart

Client-optimized language with sound null safety, behind Flutter

22 lessons · 4 hours · 4 levels · covers Dart 3.9

Dart is Google's statically typed, garbage-collected language with sound null safety, async/await, records and pattern matching. It compiles ahead of time to native code for mobile and desktop, to JavaScript or WebAssembly for the web, and runs with a JIT and hot reload during development. Learn it to build Flutter apps and command-line or server tools in one approachable language.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics8 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms15 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs19 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know22 lessons · 4 hours in total

The Dart tree

DartVariables, types, final and constVariables, types, finaland constSound null safetySound null safetyOperators and control flowOperators andcontrol flowFunctions and parametersFunctions andparametersLists, sets and mapsLists, sets and mapsClasses and constructorsClasses andconstructorsIterables and collection methodsIterables andcollection methodsExceptions and error handlingExceptions and errorhandlingInheritance, abstract classes and interfacesInheritance, abstractclasses and interfa…MixinsMixinsEnhanced enumsEnhanced enumsGenericsGenericsFutures and async/awaitFutures andasync/awaitRecords and patternsRecords and patternsLibraries, packages and pubLibraries, packagesand pub
Essentials and Practical shown (15 of 22 lessons); the full list is below. Click a lesson to read it.

All 22 lessons, in order

Getting started

  1. Variables, types, final and const · Essentials · 10 min

    Declare variables with var, final and const, use Dart's core types, and write a main function.

  2. Sound null safety · Essentials · 12 min

    Use nullable types, null-aware operators, flow analysis and late variables to write code that can't hit null errors.

  3. Operators and control flow · Essentials · 8 min

    Branch with if, switch expressions and the conditional operator, and loop with for, for-in and while.

  4. Exceptions and error handling · Essentials · 10 min

    Throw and catch exceptions with try, on, catch and finally, and know when to use Exception vs Error.

Functions and collections

  1. Functions and parameters · Essentials · 10 min

    Write functions with positional, optional and named parameters, arrow syntax and closures.

  2. Lists, sets and maps · Essentials · 12 min

    Use List, Set and Map literals, collection if and for, and the spread operator.

  3. Iterables and collection methods · Essentials · 10 min

    Transform data with map, where, fold, expand and any, and understand that Iterable operations are lazy.

Classes and types

  1. Classes and constructors · Essentials · 14 min

    Define classes with fields, getters, methods and the many constructor forms: initializing formals, named, const and factory.

  2. Inheritance, abstract classes and interfaces · Practical · 12 min

    Extend classes, override members, write abstract classes, and implement any class as an interface.

  3. Mixins · Practical · 10 min

    Reuse behavior across unrelated classes with mixin declarations and the with clause.

  4. Enhanced enums · Practical · 8 min

    Declare enums with fields, constructors, methods and interfaces, and switch over them exhaustively.

  5. Generics · Practical · 10 min

    Write generic classes and functions, bound type parameters with extends, and understand reified generics.

Asynchronous Dart

  1. Futures and async/await · Practical · 14 min

    Work with Future, async and await, handle errors, and run independent futures in parallel with Future.wait.

  2. Streams · Advanced · 14 min

    Consume and create streams with await for, listen, async* generators and StreamController, and know single vs broadcast.

  3. The event loop and microtasks · Expert · 14 min

    Understand Dart's single-threaded event loop, the microtask and event queues, and the exact ordering of async code.

  4. Isolates and parallelism · Expert · 14 min

    Run CPU-heavy work in parallel with Isolate.run, communicate with ports, and know what can be sent between isolates.

Records, patterns and modifiers

  1. Records and patterns · Practical · 14 min

    Return multiple values with records, and destructure and match data with patterns in variables, switch and if-case.

  2. Sealed classes and class modifiers · Advanced · 12 min

    Model closed type hierarchies with sealed classes for exhaustive switches, and control APIs with base, interface, final and mixin modifiers.

  3. Extension methods and extension types · Advanced · 12 min

    Add methods to existing types with extensions, and create zero-cost wrapper types with extension types.

Packages, testing and compilation

  1. Libraries, packages and pub · Practical · 12 min

    Organize code into libraries, import with prefixes and show/hide, and manage dependencies with pubspec.yaml and dart pub.

  2. Testing and static analysis · Advanced · 12 min

    Write unit tests with package:test, use groups, setUp and matchers, test async code, and enforce lints with the analyzer.

  3. Compilation, runtime and the type system · Expert · 16 min

    Know how Dart compiles (JIT, AOT, JS, Wasm), what soundness guarantees at run time, and how tree shaking and the GC affect apps.