Free course · 10 lessons · Beginner

Dart Fundamentals: The Language Behind Flutter

Learn modern Dart 3 from the ground up: variables and sound null safety, functions with named parameters, collections with collection-if and spread, classes and constructors, mixins and extensions, records, patterns and sealed classes, async code with futures and streams, and error handling. Every example is run with the Dart SDK and shown with its real output, ready for Flutter, servers or command-line tools.

Start the course

1. Dart Basics: Variables, Null Safety, Functions and Collections

The language Flutter is written in: variables and types, sound null safety, functions with named parameters, and collections with Dart's expressive collection syntax.

  1. Hello, Dart: Variables, Types and Strings — Write and run Dart programs, declare variables with var, final and const, use Dart's core types, and build strings with interpolation and multi-line literals.
  2. Sound Null Safety — In Dart, a String can never be null; a String? can. Learn nullable types, the ?. ?? and ??= operators, flow analysis that promotes types after checks, late variables, and why the ! operator should be rare.
  3. Functions: Named Parameters, Arrows and Closures — Dart functions are objects: pass them around, return them, and create closures. Use positional, optional and named parameters (with required and defaults), and the => arrow syntax.
  4. Lists, Maps and Sets with Collection If, For and Spread — Work with List, Map and Set, transform them with where/map/fold, and build them declaratively with collection if, collection for and the spread operator, the style Flutter UIs use everywhere.

2. Classes, Modern Dart 3 Features and Async

Classes and constructors, inheritance, mixins and extensions, Dart 3's records, patterns and sealed classes, async code with Future and Stream, error handling, and a capstone.

  1. Classes and Constructors — Define classes with fields, methods and getters, and use Dart's constructor shortcuts: this.field parameters, named constructors, initializer lists, const constructors, factory constructors and copyWith.
  2. Inheritance, Interfaces, Mixins and Extensions — Reuse behaviour with extends, define contracts with abstract classes and implements, share capabilities across unrelated classes with mixins, and add methods to existing types with extension methods.
  3. Dart 3: Records, Patterns and Sealed Classes — Return several values with records, destructure data with patterns, write exhaustive switch expressions, and model states with sealed classes so the compiler checks you handled every case.
  4. Async Dart: Future, async/await and Streams — Dart runs on an event loop: a Future is a value that arrives later, async/await makes it read like normal code, Future.wait runs work concurrently, and a Stream delivers many values over time.
  5. Errors and Exceptions in Dart — Throw and catch exceptions, use on/catch/finally, define custom exception types, rethrow with context, and know the difference between Exceptions (expected failures) and Errors (bugs).
  6. Capstone: A Todo App Core in Dart — Build the logic layer of a todo app you could put behind a Flutter UI: immutable models, a repository, filtering with sealed classes and patterns, async loading with errors, and tests. Then review it against the rubric.

Was this page helpful?