distanceTo method

  1. @override
double distanceTo(
  1. Point<num> other
)
override

Returns the distance between this and other.

var distanceTo = const Point(0, 0).distanceTo(const Point(0, 0)); // 0.0
distanceTo = const Point(0, 0).distanceTo(const Point(10, 0)); // 10.0
distanceTo = const Point(0, 0).distanceTo(const Point(0, -10)); // 10.0
distanceTo = const Point(-10, 0).distanceTo(const Point(100, 0)); // 110.0

Implementation

@override
double distanceTo(Point<num> other) {
  final dx = x - other.x;
  final dy = y - other.y;
  return sqrt(dx * dx + dy * dy);
}