getHizb static method
Get all ayat from a specific Hizb.
hizbNumber
The Hizb number (1-60)
Returns HizbResult containing all ayat in the specified Hizb.
Throws ArgumentError if hizbNumber is invalid.
Example:
final hizb = await QuranService.getHizb(1);
print('Hizb 1 contains ${hizb.totalAyat} ayat');
Implementation
static Future<HizbResult> getHizb(int hizbNumber) async {
await initialize();
_ensureDataLoaded();
QuranValidators.validateHizbNumber(hizbNumber);
final List<AyahWithSurah> hizbAyat = [];
for (final surah in _quranData!.surahs) {
for (final ayah in surah.ayat) {
if (ayah.hizb == hizbNumber) {
hizbAyat.add(AyahWithSurah(
id: ayah.id,
text: ayah.text,
sajdah: ayah.sajdah,
juz: ayah.juz,
hizb: ayah.hizb,
surah: surah,
));
}
}
}
final juzNumber = ((hizbNumber - 1) ~/ 2) + 1;
return HizbResult(
hizb: hizbNumber,
juz: juzNumber,
totalAyat: hizbAyat.length,
ayat: hizbAyat,
);
}