0Pricing
Dart Academy · Lesson

Extension Types for Zero-Cost Wrappers

Wrap a type without runtime overhead.

A Different Tool

An extension type is a newer feature: it wraps an existing type to give it a fresh interface, with no runtime cost.

Wrap Without Boxing

Unlike a real wrapper class, an extension type adds no object at runtime. At runtime it simply is the underlying value.

extension type UserId(int id) {}

All lessons in this course

  1. Writing Your First Extension
  2. Extensions on Generics
  3. Static Extension Members and Conflicts
  4. Extension Types for Zero-Cost Wrappers
← Back to Dart Academy