qibla 1.0.0 copy "qibla: ^1.0.0" to clipboard
qibla: ^1.0.0 copied to clipboard

Qibla direction, great-circle path, and haversine distance for Dart and Flutter. Pure math, zero dependencies. Computes bearing to the Ka'bah from any point on Earth.

qibla #

pub package CI License: MIT

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 #

qiblaAngle(lat, lng) #

Computes the initial bearing (forward azimuth) from the given coordinates to the Ka'bah.

Parameter Type Description
lat double Latitude in decimal degrees (-90 to 90)
lng double Longitude in decimal degrees (-180 to 180)
Returns double Bearing in degrees clockwise from north (0-360)

Throws RangeError if coordinates are out of bounds.

compassDir(bearing) #

Eight-point compass abbreviation: N, NE, E, SE, S, SW, W, NW.

compassName(bearing) #

Full compass name: North, Northeast, East, Southeast, South, Southwest, West, Northwest.

qiblaGreatCircle(lat, lng, [steps]) #

Generates waypoints along the great circle from (lat, lng) to the Ka'bah using spherical linear interpolation (Slerp). Returns steps + 1 points (default: 121).

Useful for drawing Qibla direction lines on maps.

distanceKm(lat1, lng1, lat2, lng2) #

Haversine distance between two points in kilometers (spherical Earth approximation, R = 6,371 km).

Constants #

Name Value Description
kaabaLat 21.422511 Ka'bah center latitude (degrees north)
kaabaLng 39.826150 Ka'bah center longitude (degrees east)
earthRadiusKm 6371 WGS-84 volumetric mean radius

Compatibility #

Dart 3.7+. Works with Flutter and standalone Dart applications.

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

License #

MIT

0
likes
150
points
99
downloads

Documentation

API reference

Publisher

verified publisherariccamarata.com

Weekly Downloads

Qibla direction, great-circle path, and haversine distance for Dart and Flutter. Pure math, zero dependencies. Computes bearing to the Ka'bah from any point on Earth.

Repository (GitHub)
View/report issues

Topics

#qibla #islamic #compass #geodesic #geolocation

License

MIT (license)

More

Packages that depend on qibla