getTopPoint method Null safety

Point<num> getTopPoint(
  1. List<Point<num>> polygon
)

Get the furthest top point of the polygon

Implementation

static Point getTopPoint(List<Point> polygon) {
  assert(polygon.length >= 3);
  var topPoint = Point<num>(double.negativeInfinity, double.negativeInfinity);

  for (var p in polygon) {
    if (p.y > topPoint.y) {
      topPoint = p;
    }
  }

  return topPoint;
}