iamriajul / adhan-dart

Adhan for Dart / Muslim Prayer Times Library. Now retrieving Prayer time in Dart easier than ever.
https://pub.dev/packages/adhan
MIT License
86 stars 41 forks source link

Latitute bigger than 75 throws an exception #61

Open MuhammadSwa opened 4 months ago

MuhammadSwa commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce


**Expected behavior**
Latitude maxium value should be 90 not 75

**Environment(please complete the following information):**
 - Dart Language Version: [e.g. Dart 3.3.4]
 - Adhan-Dart Version: [2.0.0+1]
moha-b commented 4 months ago

The issue description is unclear. Can you please provide more details or clarify what you meant?

MuhammadSwa commented 4 months ago

PrayerTimes? getPrayersTimes({required double latitude, required double longitude}) { final myCoordinates = Coordinates(latitude, longitude,validate: true); final params = CalculationMethod.egyptian.getParameters(); params.madhab = Madhab.shafi; return PrayerTimes.today(myCoordinates, params); }

- In class Coordinates, any latitude between -90 and 90 is accepted. Any longitude between -180 and 180 should be accepted.
```dart
  Coordinates(this.latitude, this.longitude, {bool validate = false}) {
    if (validate) {
      if (!(latitude.isFinite && latitude.abs() <= 90)) {
        throw ArgumentError(
            'Invalid Latitude supplied, Latitude must be a number between -90 and 90');
      }

      if (!(longitude.isFinite && longitude.abs() <= 180)) {
        throw ArgumentError(
            'Invalid longitude supplied, Longitude must a number between -180 and 180');
      }
    }
  }
moha-b commented 4 months ago

May I ask why you're using static lat and lon? It should be dynamic and come from packages like geolocator

MuhammadSwa commented 4 months ago

I'm actually doing that this is just a simplified version of my application to demonstrate the problem. Did you run the code? Is the problem reproducable?

moha-b commented 4 months ago

I have executed the code, and it generated the same error, but it seems to be identifying it as NaN for some reason. However, I am not entirely sure what is causing the issue. It could be possible that this particular location is causing the problem because it's an ocean, which might be a factor. Nonetheless, I'm uncertain about the root cause of the problem.

MuhammadSwa commented 4 months ago

Okay thanks for your effort