iamriajul / adhan-dart Goto Github PK
View Code? Open in Web Editor NEWAdhan for Dart / Muslim Prayer Times Library. Now retrieving Prayer time in Dart easier than ever.
Home Page: https://pub.dev/packages/adhan
License: MIT License
Adhan for Dart / Muslim Prayer Times Library. Now retrieving Prayer time in Dart easier than ever.
Home Page: https://pub.dev/packages/adhan
License: MIT License
Midnight calculation should be from Isha (end of sun light) to Fajr (beginning of sun light) / 2 not from Maghrib to Fajr / 2.
I hope this help developer in the next update.
Question related to which version: [eg: v1, v2, common]
[Describe the question and your situation]
======== Exception caught by widgets library =======================================================
The following FormatException was thrown building HomeContentPrayerTimeItem(dirty):
ishaAngle's value isn't define
Describe the bug
when choosing "umm alqura uni, mekka" as a calculation method with "hanafi" as a madhab and "based on angle" as a high latitude rule the plugin returns an exception, this isn't supposed to happen.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The plugin must not return this exception
Environment(please complete the following information):
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
PrayerTimes? getPrayersTimes() {
const double latitude = 76;
const double longitude = 179;
final myCoordinates = Coordinates(latitude, longitude,validate: true);
final params = CalculationMethod.egyptian.getParameters();
params.madhab = Madhab.shafi;
final PrayerTimes prayerTimes = PrayerTimes.today(myCoordinates, params);
return prayerTimes;
}
Expected behavior
Latitude maxium value should be 90 not 75
Environment(please complete the following information):
Always getting output
I/flutter (15669): Next Prayer Prayer.maghrib
I/flutter (15669): Current Prayer Prayer.asr
with
Prayer nextPrayerTimes = prayerTimes.nextPrayer();
print("Next Prayer $nextPrayerTimes");
Prayer currentPrayer = prayerTimes.currentPrayer();
print("Current Prayer $currentPrayer");
The test for calculating prayer times in Egypt is failing due to an inconsistency in the Dhuhr prayer time.
Here's a breakdown of the issue:
Expected Dhuhr Time: 11:53 AM
Actual Dhuhr Time: 11:54 AM
Difference: 1 minute later than expected
The ASR prayer is also included, but the difference is 1 hour
and 1 minute
.
this is the successful state
test('Test Prayer Time in Egypt', () {
final coordinates = Coordinates(26.0590358, 32.2320519);
final date = DateComponents.from(DateTime.now());
final params = CalculationMethod.egyptian.getParameters();
params.madhab = Madhab.hanafi;
final prayerTimes = PrayerTimes(coordinates, date, params);
expect(DateFormat.jm().format(prayerTimes.fajr), '4:10 AM');
expect(DateFormat.jm().format(prayerTimes.sunrise), '5:36 AM');
expect(DateFormat.jm().format(prayerTimes.dhuhr),
'11:54 AM'); // 11:53 based on Google
expect(DateFormat.jm().format(prayerTimes.asr),
'4:24 PM'); // 3:23 based on Google
expect(DateFormat.jm().format(prayerTimes.maghrib), '6:11 PM');
expect(DateFormat.jm().format(prayerTimes.isha), '7:27 PM');
});
Describe the bug
Adhan package return wrong prayer times, it added two hour to real time/other prayer time app.
To Reproduce
Steps to reproduce the behavior:
CalculationParameters(
madhab: Madhab.shafi,
fajrAngle: 20,
ishaAngle: 18,
highLatitudeRule: HighLatitudeRule.twilight_angle,
)
Screenshots
Here is the screenshot from my app
And here is screenshot of prayer times of same city on online prayer time
You can see that this package return +2 hours to the desired time
Environment(please complete the following information):
I noticed that the adhan-dart is giving plus 1hr for Asr time. For example I was expecting to give 17:15 instead of 18:15.
Do you know why?
final params = CalculationMethod.karachi.getParameters();
params.madhab = Madhab.hanafi;
prayerTimes = PrayerTimes.today(myCoordinates, params, utcOffset: _dateTime.timeZoneOffset);
Is there anyway to obtain the 'sunset' time ?
Hello brother
Does this package adjust prayer times with regard to summer time variation?
I have this code
final myCoordinates = Coordinates(21.416667938232425, 39.81666564941406); // Replace with
final MaccaTime = Duration(hours: 3);
final date = DateComponents.from(DateTime.now());
final params = CalculationMethod.umm_al_qura.getParameters();
params.madhab = Madhab.hanafi;
params.adjustments.fajr = -1;
final prayerTimes =PrayerTimes(myCoordinates, date, params, utcOffset: MaccaTime);
var nextPrayerTimes = prayerTimes.nextPrayer();
print("nextPrayerTimes "+ nextPrayerTimes.toString() );
final nextPrayerTime = prayerTimes.timeForPrayer(nextPrayerTimes);
final startTime = DateTime(nextPrayerTime.year, nextPrayerTime.month,
nextPrayerTime.day,
nextPrayerTime.hour,
nextPrayerTime.minute);
final currentTime = DateTime.now();
final diff_dy = startTime.difference(currentTime).inDays;
final diff_hr = startTime.difference(currentTime).inHours;
final diff_mn = startTime.difference(currentTime).inMinutes;
final diff_sc = startTime.difference(currentTime).inSeconds;
print(diff_dy);
print(diff_hr);
print(diff_mn);
print(diff_sc/60);
it's Should Show next player is Isha
but it shows Asr
I/flutter ( 3343): nextPrayerTimes Prayer.asr
I/flutter ( 3343): 0
I/flutter ( 3343): -2
I/flutter ( 3343): -130
I/flutter ( 3343): -130.13333333333333
How to get UTC offset to determine correct timings for every region. Like you have mentioned New York UTC offset which is -4 in hours. But how can we get UTC offset for every region in this format from latitude and longitude.
For example in pakistan's almost every city is giving correct adhan time while in istanbul or some other location its time is one hour earlier than original. why?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
Additional context
I tried to get prayer times for Palestine Gaza but all times are one hour late
static CalculationMethod calculationMethod = CalculationMethod.egyptian;
static Madhab madhab = Madhab.shafi;
no high latitude rule
final prayerTimes = PrayerTimes(
coordinates,
DateComponents.from(
dateTime,
),
CalculationParametersAdjustments.getCalculationParameters(),
);
"latitude": "31.50170000",
"longitude": "34.46680000"
in this link fajr at 4:25 but the package return 3:25 and so on for all other prayers
but the timing is correct for countries like egypt
can you please check it or give an explanation for that?
Dart null safety: https://dart.dev/null-safety
Describe the bug
Prayer times with the Muslim World League parameters appear to be incorrect.
To Reproduce
Steps to reproduce the behavior:
Create a PrayerTimes object with coordinates (51.5074, 0.1278) [The coordinates of London] and DateComponents(2021, 5, 26), and the Muslim World League parameters, like so:
PrayerTimes( Coordinates(51.5074, 0.1278), DateComponents(2021, 5, 26), CalculationMethod.muslim_world_league.getParameters(), )
Then print out the DateTime objects for Fajr and Isha, and you'll end up with the following:
flutter: 2021-05-26 00:57:00.000 flutter: 2021-05-27 00:31:00.000
Expected behavior
These prayer times are incorrect, and according to IslamicFinder.org with the same coordinates and calculation method, the following should be output instead:
Environment(please complete the following information):
Perhaps there is a way to alleviate this issue/a setting that I have not been using, in which case I apologise. Jazakallah for developing this package and may Allah reward you!
At the address below, the Diyanet's prayer times for Istanbul are shown:
https://namazvakitleri.diyanet.gov.tr/en-US/9541/prayer-time-for-istanbul
All prayer times are calculated correctly. But the asr is wrong. How can I solve this problem?
Here is the code I use to get Prayer Times:
print('My Prayer Times');
final myCoordinates = Coordinates(41.015137, 28.979530); // Istanbul
final params = CalculationMethod.turkey.getParameters();
params.madhab = Madhab.hanafi;
final prayerTimes = PrayerTimes.today(myCoordinates, params);
print(
"---Today's Prayer Times in Your Local Timezone(${prayerTimes.fajr.timeZoneName})---");
print(DateFormat.jm().format(prayerTimes.fajr));
print(DateFormat.jm().format(prayerTimes.sunrise));
print(DateFormat.jm().format(prayerTimes.dhuhr));
print(DateFormat.jm().format(prayerTimes.asr)); // -> Asr time is calculated incorrectly
print(DateFormat.jm().format(prayerTimes.maghrib));
print(DateFormat.jm().format(prayerTimes.isha));
print('---');
Assalamu Alaykum : )
May there be peace upon you.
The adhan-dart is very cheering, empowering, and an excellent means to serve the nation. I am glad and thankful to Allah that I came across the package. And I would like to cheer up the team who worked on it!
I am having trouble setting up the adhan-dart.
So, What I have done:
I am posting down my main.dart and prayer.dart file with the errors.
I will feel elevated to be helped.
Salam brother..
thanks for developing this package..
.
I have this error when running the example even though the pray time is generated.
'
Hope you can address this issue.
E/flutter (29148): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: setState() called after dispose(): _TodayKuliahMasjidWaktuSolatPageState#fe309(lifecycle state: defunct, not mounted) E/flutter (29148): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. E/flutter (29148): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. E/flutter (29148): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
Question related to which version: 2.0.0-nullsafety.2
Is there any method that returns the remaining time to the next prayer? Looking at the documentation, I only see that I can get the current date but nothing else.
Currently, when I use CalculationMethod.muslim_world_league or other, the adhan time is different.
Assalam Alaykom Brother
Thank you very much for the plugin........ Jazak Allah Khair
I just tried the plugin in the iphone simulator and also in my iphone devise but it does not work. I get this message on screen: "Waiting for your Location..."
I have waited for long time without any result. Can you pleas check.
I have used the example code you placed in GitHub :
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final location = new Location();
String locationError;
PrayerTimes prayerTimes;
@override
void initState() {
getLocationData().then((locationData) {
if (mounted) {
return;
}
if (locationData != null) {
setState(() {
prayerTimes = PrayerTimes(Coordinates(locationData.latitude, locationData.longitude),
DateComponents.from(DateTime.now()), CalculationMethod.karachi.getParameters());
});
} else {
setState(() {
locationError = "Couldn't Get Your Location!";
});
}
});
super.initState();
}
Future<LocationData> getLocationData() async {
var _serviceEnabled = await location.serviceEnabled();
if (!_serviceEnabled) {
_serviceEnabled = await location.requestService();
if (!_serviceEnabled) {
return null;
}
}
var _permissionGranted = await location.hasPermission();
if (_permissionGranted == PermissionStatus.denied) {
_permissionGranted = await location.requestPermission();
if (_permissionGranted != PermissionStatus.granted) {
return null;
}
}
return await location.getLocation();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: <Widget>[
Builder(
builder: (BuildContext context) {
if (prayerTimes != null) {
return Column(
children: [
Text(
'Prayer Times for Today',
textAlign: TextAlign.center,
),
Text('Fajr Time: ' + DateFormat.jm().format(prayerTimes.fajr)),
Text('Sunrise Time: ' + DateFormat.jm().format(prayerTimes.sunrise)),
Text('Dhuhr Time: ' + DateFormat.jm().format(prayerTimes.dhuhr)),
Text('Asr Time: ' + DateFormat.jm().format(prayerTimes.asr)),
Text('Maghrib Time: ' + DateFormat.jm().format(prayerTimes.maghrib)),
Text('Isha Time: ' + DateFormat.jm().format(prayerTimes.isha)),
],
);
}
if (locationError != null) {
return Text(locationError);
}
return Text('Waiting for Your Location...');
},
)
],
),
),
);
}
}
Please Update your project to null safety.
Anyway to calculate iqamah time for prayer?
Describe the bug
when selecting the following settings the app crashes:
high latitude rule = twilight angle
madhab = hanafi
calculation method = umm al-qura
ishaAngle's value isn't define
When the exception was thrown, this was the stack:
#0 CalculationParameters.nightPortions (package:adhan/src/calculation_parameters.dart:73:13)
#1 new PrayerTimes._ (package:adhan/src/prayer_times.dart:169:49)
#2 new PrayerTimes (package:adhan/src/prayer_times.dart:53:24)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
Additional context
Add any other context about the problem here.
dear authors , I am new at flutter and i want to make an app for namaz timing and your api is perfect for me and i want to know that how i can program your api that api automatically detect coordinates based on device location and give results hope you will soon answer my question
Asr timings calculation is not correct please have a look.
CalculationMethod.egyptian fajrAngle is 20.0 and ishaAngle is 18.0 but they should be 19.5 and 17.5 instead.
Describe the bug
latitude values between (-67.5944046 and -90) and between (65.9277379 and 90)
throw Unhandled exception!
To Reproduce
minimum code that reproduce the error:
import 'package:adhan/adhan.dart';
void main() async {
//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);
}
Expected behavior
should output the actual time of the giving parameters.
but it throws an error:
C:/Flutter_SDK/flutter/bin/cache/dart-sdk/bin/dart.exe --enable-asserts "E:\Flutter_UI\hij_greg_temp - Copy\lib\main.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.<anonymous closure> (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.
Environment(please complete the following information):
Salam Alaykum.
when I enter the app with the location service disable, I get a dialog to allow the service, when I tap ok it is not updating the screen and keeps saying "Waiting for Your Location..." !!!
Need to implement features accepted to adhan-js: batoulapps/adhan-js#30
Issue came From: batoulapps/adhan-kotlin#26
Question related to which version: Common
I have a question about Isha prayer exactly after Isha prayer. So once Isha is done I'm getting a none
enum case and I want to show Fajr for the next day.. I tried with:
void _getPrayersForTomorrow() { var newDate = new DateTime(nextPrayerTime.value.year, nextPrayerTime.value.month, nextPrayerTime.value.day + 1); nextPrayer.value = prayerTimes.value.nextPrayerByDateTime(newDate); }
but I still get none
as praying time... is there any workaround to archive that?
Selam
Hello Brother.
There are issues with current preyer and next prayer , if you can pleas check and fix.
The issues are as follows:
1- if the current preayer is showing as (Prayer.isha) then the next Prayer is showing (Prayer.none). it should show (Prayer.fajr).
2- if the time is now is after the Sunrise time, it shows (Prayer.sunrise). there is not prayer as sunrise.
Also I have some suggestion to add more time calculations as follows:
1- can you please add (next prayer) is after ....... (count down time)
2- can you please add the time of mid-night (calculated as the mean time from sunset to fajr)
3- can you please add the start time of the last third of the night.
(duration between sunset and fajr / 3 = i) (i + i + sunset time = start time of the last third of the night)
Question related to which version: common
I read docs but can't find about it. I do not have detailed information about calculating adhan times. I tried in Turkey with muslim_world_league method its giving wrong times. Can i automize the calculation parameters based on location?
e.g
location is Turkey use CalculationMethod.Turkey
location is NA use CalculationMethod.north_america.
location is kuwait use CalculationMethud.kuwait
Thanks for help.
Hello @iamriajul , this package is outdated. can you please update it to be compatible with Dart 3 and null safety
Prayer time of London mismatches. please add London central mosque time
testing
🧪 . It will tell everyone how to test the package and what rules to follow. This will help us test better and make our software nicer. 🚀What do you think of this article that says fixed degree around the year is not correct in places with high latitudes and low latitudes.
see the link below:
How to use Method timeForPrayer, nextPrayerByDateTime end etc
Question related to which version: [eg: v1, v2, common]
[Describe the question and your situation]
tz.initializeTimeZones();
String timeZoneName = tzmap.latLngToTimezoneString(lat, lng);
var timeZoneLocation = tz.getLocation(timeZoneName);
final tz.TZDateTime now = tz.TZDateTime.now(timeZoneLocation);
var timeInUtc = DateTime.utc(1970, 1, 1);
var timeZone =
timeZoneLocation.timeZone(timeInUtc.millisecondsSinceEpoch);
print(timeZone.offset);
currentLocation = cityName;
setState(() {
final methodParams = selectedMethod != null
? selectedMethod.getParameters()
: adhan.CalculationMethod.tehran.getParameters();
methodParams.madhab =
selectedMazhab != null ? selectedMazhab : adhan.Madhab.hanafi;
methodParams.highLatitudeRule = selectedLatitude != null
? selectedLatitude
: adhan.HighLatitudeRule.middle_of_the_night;
prayerTimes = adhan.PrayerTimes(adhan.Coordinates(lat, lng),
adhan.DateComponents.from(now), methodParams,
utcOffset: Duration(milliseconds: timeZone.offset));
This is how i calculate prayer times but in new york it has one hour deff, and for newyork offset value is -18000000 in millis.
Hello Brother
I just noticed that highLatitudeRule does not work, i.e when I change to different rules (middle_of_the_night, seventh_of_the_night & twilight_angle
) nothing changes in the prayer times of fajr and isha.
can you please clarify this?
Assalam 3alaykom,
First of all, thanks for this nice package, it works like a charm and the documentation is really nice.
While implementing your package in my app, I noticed the calculation method of Tehran wasn't available, so I tried to implement the CalculationParameters myself, but I realised that the maghribAngle wasn't implemented in this Dart.
Would it be possible to implement it inshaAllah ?
Here's the JS version: https://github.com/batoulapps/adhan-js/blob/master/src/CalculationParameters.js
Many thanks!
it will better to add Ishraq, Chast Prayer Time
time prayer not show,.
only text waiting for your location.
thanks
please make response string because im so confuse how to parse prayerTimes to fajr,sunrise or maghrib
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.