Skip to content
pubscout

haversine_distance

1.2.1, released 6 years ago by an unverified publisher

Calculate the distance between two latitude and longitude coordinates

WASM-ready
$ flutter pub add haversine_distance
Source repository

What it does

A Dart package that computes the geographic distance between two location coordinates using the Haversine formula. It supports multiple distance units including kilometers, meters, miles, and nautical miles.

AI-written summary of version 1.2.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to calculate distances between coordinates without relying on external mapping SDKs
  • You want simple distance calculations in kilometers, meters, miles, or nautical miles

Skip it when

  • You need full map rendering or geolocation tracking
  • You require route optimization or turn-by-turn navigation

Strengths

  • Simple and lightweight API
  • Supports multiple measurement units
  • No external dependencies

Weaknesses

  • Limited to basic distance calculation
  • Does not include built-in mapping widgets or location tracking

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0

none

final startCoordinate = new Location(60.389739, 5.322323);
final endCoordinate = new Location(60.393032, 5.327248);
final haversineDistance = HaversineDistance();
final distance = haversineDistance.haversine(startCoordinate, endCoordinate, Unit.KM);

Alternatives

Packages that do the same job and could replace haversine_distance.

  • geolocator

    Choose this if you need device geolocation services, permissions, and built-in distance calculation functions.

  • latlong2

    Choose this if you are already using flutter_map and need geospatial calculations along with map rendering.