0PricingLogin
Dart Academy · Lesson

Writing Your First Extension

Bolt new methods onto a built-in type.

Methods You Cannot Add

Ever wished int had a handy method it just does not have? You cannot edit the built-in class, but Dart gives you another way in.

Meet the extension

An extension lets you bolt new methods onto an existing type without subclassing or touching its source. 🎁

extension on String {
  // new methods go here
}

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