nearestPoint method
Implementation
Point<num>? nearestPoint(List<Point<num>>? points, Point<num> p) {
if (points == null || points.isEmpty) return null;
Point<num>? nearest;
double? nearestDistance;
for (var point in points) {
var distance = point.distanceTo(p);
if (nearestDistance == null || distance < nearestDistance) {
nearest = point;
nearestDistance = distance;
}
}
return nearest;
}