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
- Writing Your First Extension
- Extensions on Generics
- Static Extension Members and Conflicts
- Extension Types for Zero-Cost Wrappers