Instance methods

Instance methods

import 'dart:math'; 
class Point { 
   num x, y; 

   Point(this.x, this.y); 

   num distanceTo(Point other) { 
      var dx = x - other.x; 
      var dy = y - other.y; 
      return sqrt(dx * dx + dy * dy); 
   } 
}

Instance methods on objects can access instance variables and this.

Related concepts

Instance methods — Structure map

Clickable & Draggable!

Instance methods — Related pages: