โ๏ธ Author
Vansh Bhardwaj
๐ง vanshbhardwajhere@gmail.com
๐ GitHub
find_min_distance
A Dart utility package to calculate the minimum distance between two geographical locations using their latitude and longitude coordinates.
It uses the Haversine formula to accurately compute great-circle distances between points on a sphere.
๐ Features
- ๐ Pure Dart implementation โ no external dependencies
- ๐ Calculate geo-distance in kilometers
- ๐งฎ Uses Haversine formula for high accuracy
- โ Fully tested & documented
- ๐งฉ Works in both Flutter and pure Dart projects
๐ฆ Installation
Add this to your pubspec.yaml
:
dependencies:
find_min_distance: ^1.0.2
Then, run:
flutter pub get
or for Dart only:
dart pub get
๐ป Usage Example
import 'package:find_min_distance/find_min_distance.dart';
void main() {
double lat1 = 28.7041; // New Delhi
double lon1 = 77.1025;
double lat2 = 19.0760; // Mumbai
double lon2 = 72.8777;
// Calculate minimum distance in KM
double distance = calculateMinDistance(lat1, lon1, lat2, lon2);
print("The distance between New Delhi and Mumbai is ${distance.toStringAsFixed(2)} km");
}
๐ Output:
The distance between New Delhi and Mumbai is 1153.24 km
๐ง How it Works (Haversine Formula)
The Haversine formula determines the great-circle distance between two points on a sphere using their latitudes and longitudes.
It is ideal for calculating as-the-crow-flies distances over the Earthโs surface.
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
Libraries
- find_min_distance
- Support for doing something awesome.