contains method
Returns true
if the given location is inside the area.
Calculates the distance using the Haversine algorithm.
Accuracy can be out by 0.3%.
Implementation
bool contains(double lon, double lat) {
final f1 = _degToRadian(latitude);
final f2 = _degToRadian(lat);
final sinDLat = math.sin((f2 - f1) / 2);
final sinDLng = math.sin((_degToRadian(longitude) - _degToRadian(lon)) / 2);
// Sides
final a =
sinDLat * sinDLat + sinDLng * sinDLng * math.cos(f1) * math.cos(f2);
final c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));
return _earthRadius * c < radius;
}