Skip to content
Justice Tech School

Extension Methods

extension adds methods to existing types.

Example
extension Shout on String {
  String shout() => toUpperCase() + "!";
}
extension on int {
  bool get isBig => this > 100;
}
void main() {
  print("hi".shout());
  print(500.isBig);
}

Exercise

Extend String.

 Shout on String {}

Quiz Test

What does on name?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.