geo_distance_calculator 1.1.2 copy "geo_distance_calculator: ^1.1.2" to clipboard
geo_distance_calculator: ^1.1.2 copied to clipboard

A simple Flutter library for calculating the distance between two geographical points using the Haversine formula.

GeoDistanceCalculator #

A simple Flutter library for calculating the distance between two geographical points using the Haversine formula.

Features #

  • Calculate the great-circle distance between two points on Earth.
  • Simple and easy-to-use API.

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  geo_distance_calculator: ^1.0.0

Then, run the following command:

flutter pub get

Or, if you're using Dart:

dart pub get

Usage #

Import the package into your Dart file:

import 'package:geo_distance_calculator/geo_distance_calculator.dart';

You can then use the GeoDistanceCalculator class to calculate the distance between two geographical points:

double distance = GeoDistanceCalculator.calculateDistance(
  startLatitude: 37.7749,
  startLongitude: -122.4194,
  endLatitude: 34.0522,
  endLongitude: -118.2437,
);

print('The distance is $distance kilometers');

Example #

void main() {
  double distance = GeoDistanceCalculator.calculateDistance(
    startLatitude: 21.0285,  // Hanoi
    startLongitude: 105.8542,
    endLatitude: 10.8231,    // Ho Chi Minh City
    endLongitude: 106.6297,
  );

  print('The distance between Hanoi and Ho Chi Minh City is $distance kilometers');
}

License #

This project is licensed under the MIT License - see the LICENSE file for details.

3
likes
130
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A simple Flutter library for calculating the distance between two geographical points using the Haversine formula.

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on geo_distance_calculator