Open MuhammadSwa opened 4 months ago
The issue description is unclear. Can you please provide more details or clarify what you meant?
This is a sample program to produce the error with the given package version
void main() {
final p1 = getPrayersTimes(latitude: 74, longitude: 179); // this works as expected
final p2 = getPrayersTimes(latitude: 74, longitude: -179); // this works as expected/
final p3 = getPrayersTimes(latitude: 75, longitude: 179); //this throws an error
}
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');
}
}
}
Longitude values always works as expected, any value is valid between -180 and 180. see p1
and p2
.
But if you pass latitude values >= 75, the Coordinates
class validates it correctly but somewhere else in the code is throws an error like this one below
Unhandled exception:
Invalid argument(s): value should not be infinite or NaN
#0 TimeComponents.fromDouble (package:adhan/src/data/time_components.dart:12:7)
#1 new PrayerTimes._ (package:adhan/src/prayer_times.dart:142:24)
#2 new PrayerTimes.today (package:adhan/src/prayer_times.dart:68:24)
#3 getPrayersTimes (package:test_app/main.dart:14:47)
#4 main (package:test_app/main.dart:7:14)
#5 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
if i failed to demonstrate the problem, please let me know exactly what's unclear.
May I ask why you're using static lat
and lon
? It should be dynamic and come from packages like geolocator
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?
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.
Okay thanks for your effort
Describe the bug A clear and concise description of what the bug is.
To Reproduce
when running this function you get the error.