纬度大于65:错误值不应该是无限或NaN,使用adhan包



纬度值介于(-67.5944046和-90)和(65.9277379和90)之间抛出未处理异常!

产生错误的最小代码:

import 'package:adhan/adhan.dart';
void main() {
//latitude values between (-67.5944046 and -90) and between (65.9277379 and 90)
//throw Unhandled exception!
// var prayerTimes = PrayerTimes(Coordinates(-67.5944046, 120),
// DateComponents.from(DateTime.now()), CalculationMethod.umm_al_qura.getParameters());
var prayerTimes = PrayerTimes(Coordinates(65.9277379, 120),
DateComponents.from(DateTime.now()), CalculationMethod.umm_al_qura.getParameters());
print(prayerTimes.fajr);
}

预期行为应输出给定参数的实际祈祷时间。

但是会抛出错误:

C:/Flutter_SDK/flutter/bin/cache/dart-sdk/bin/dart.exe --enable-asserts "E:Flutter_UIhij_greg_temp - Copylibmain.dart"
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:133:37)
#2 new PrayerTimes (package:adhan/src/prayer_times.dart:53:24)
#3 main (package:hij_greg_temp/main.dart:10:21)
#4 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:297:19)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Process finished with exit code 255

run flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, 3.1.0-9.0.pre, on Microsoft Windows [Version 10.0.19043.1766], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[√] Chrome - develop for the web
[!] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.11.1)
X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
MSVC v142 - VS 2019 C++ x64/x86 build tools
- If there are multiple build tool versions available, install the latest
C++ CMake tools for Windows
Windows 10 SDK
[√] Android Studio (version 2021.1)
[√] Android Studio (version 4.1)
[√] Android Studio (version 4.2)
[√] VS Code (version 1.68.1)
[√] Connected device (4 available)
[√] HTTP Host Availability
! Doctor found issues in 1 category.

adhan - dart Version: [adhan: ^2.0.0-nullsafety.2]

注意:以前的版本(adhan: ^1.1.14)工作得很好,但我不能再使用它了,因为它不提供nullsafety。

尝试使用验证参数设置为false,就像这样

var prayerTimes = PrayerTimes(Coordinates(65.9277379, 120, validate: false),
DateComponents.from(DateTime.now()), CalculationMethod.umm_al_qura.getParameters());

或者从repo中提取源代码,自己在库代码中添加null安全,然后给出合并请求。一旦开发人员接受,您就可以毫无问题地使用它了。

最新更新