findClosest method

GeoLocationNode? findClosest(
  1. GeoCoords target
)

Finds the GeoLocationNode (City, Region, or Country) instance closest to the provided target

Returns: A City when possible, otherwise a Region or a Country, whichever is more specific.

Implementation

GeoLocationNode? findClosest(GeoCoords target) {
  var region = states.findClosestTo(target);
  if (region == null) return this;
  return region.findClosestCity(target) ?? region;
}