Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

dart static method

import 'dart:math';

void main() {
  Point point1 = Point(1, 1);
  Point point2 = Point(10, 10);

  double distance = Point.distanceBetween(point1, point2);

  print(distance);
}

class Point {
  double x, y;
  Point(this.x, this.y);

  static double distanceBetween(Point a, Point b) {
    var dx = a.x - b.x;
    var dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
  }
}
 
PREVIOUS NEXT
Tagged: #dart #static #method
ADD COMMENT
Topic
Name
9+1 =