Qibla direction, great-circle path, and haversine distance for Dart/Flutter. Pure math, zero dependencies.
Find a file
2026-05-30 20:16:28 -04:00
.github docs: add wiki docs (P1) 2026-05-30 20:16:28 -04:00
lib docs: portfolio polish — README, wiki, examples 2026-05-30 18:35:21 -04:00
test Initial release: qibla v1.0.0 2026-03-08 12:58:43 -04:00
.editorconfig style: replace em dashes with colons; add .editorconfig 2026-03-08 17:28:08 -04:00
.gitignore Initial release: qibla v1.0.0 2026-03-08 12:58:43 -04:00
analysis_options.yaml Initial release: qibla v1.0.0 2026-03-08 12:58:43 -04:00
CHANGELOG.md chore: merge dart-gap-fill — v1.0.1 parity audit, CHANGELOG, pubspec fix 2026-05-30 18:35:44 -04:00
LICENSE Initial commit 2026-03-08 12:53:02 -04:00
pubspec.yaml fix: remove invalid publisher field, add CHANGELOG, untrack agent config 2026-05-29 15:59:01 -04:00
README.md docs: portfolio polish — README, wiki, examples 2026-05-30 18:35:21 -04:00

qibla

pub package CI License: MIT wiki

Qibla direction, great-circle path, and haversine distance for Dart and Flutter. Pure math, zero dependencies.

Installation

dependencies:
  qibla: ^1.0.0

Quick Start

import 'package:qibla/qibla.dart';

// Bearing from New York to the Ka'bah
final bearing = qiblaAngle(40.7128, -74.006);
print(bearing);             // ~58.48
print(compassDir(bearing)); // NE

// Distance in kilometers
final km = distanceKm(40.7128, -74.006, kaabaLat, kaabaLng);
print(km); // ~9634

API

Function Returns Description
qiblaAngle(lat, lng) double Bearing to Ka'bah, degrees clockwise from north
compassDir(bearing) String Eight-point abbreviation: N, NE, E, SE, S, SW, W, NW
compassName(bearing) String Full name: North, Northeast, ...
qiblaGreatCircle(lat, lng, [steps]) List<List<double>> Great-circle waypoints to the Ka'bah
distanceKm(lat1, lng1, lat2, lng2) double Haversine distance in km

Constants: kaabaLat (21.422511), kaabaLng (39.82615), earthRadiusKm (6371).

Full reference: API Reference.

Architecture

All calculations use the forward azimuth formula from spherical trigonometry. Great-circle paths use Slerp. Distance uses the haversine formula. Ka'bah coordinates are fixed constants verified against published GPS surveys.

Compatibility

Dart 3.7+. Works with Flutter and standalone Dart.

  • qibla (npm) - The TypeScript version of this package.
  • pray-calc-dart - Islamic prayer times calculator for Dart.

License

MIT