getPolygonFurthestVertexFromCentroid method Null safety

Point<num> getPolygonFurthestVertexFromCentroid(
  1. List<Point<num>> list,
  2. Point<num> centroid
)

Get the furthest vertex

only used with centroid of inner circle. since centroid of outer circle always has same distance to all vertices

Implementation

static Point getPolygonFurthestVertexFromCentroid(
    List<Point> list, Point centroid) {
  assert(list.length >= 3);
  Point furthest = centroid;

  num distance = 0;
  for (var p in list) {
    final d = centroid.distanceTo(p);
    if (d > distance) {
      distance = d;
      furthest = p;
    }
  }
  return furthest;
}