getVersesTextByPage function

List<String> getVersesTextByPage(
  1. int pageNumber, {
  2. bool verseEndSymbol = false,
  3. SurahSeperator surahSeperator = SurahSeperator.none,
  4. String customSurahSeperator = "",
})

Takes pageNumber, verseEndSymbol, surahSeperator & customSurahSeperator and returns the list of verses in that page if customSurahSeperator is given, surahSeperator will not work.

Implementation

List<String> getVersesTextByPage(int pageNumber,
    {bool verseEndSymbol = false,
    SurahSeperator surahSeperator = SurahSeperator.none,
    String customSurahSeperator = ""}) {
  if (pageNumber > 604 || pageNumber <= 0) {
    throw "Invalid pageNumber";
  }

  List<String> verses = [];
  final pageData = getPageData(pageNumber);
  for (var data in pageData) {
    if (customSurahSeperator != "") {
      verses.add(customSurahSeperator);
    } else if (surahSeperator == SurahSeperator.surahName) {
      verses.add(getSurahName(data["surah"]));
    } else if (surahSeperator == SurahSeperator.surahNameArabic) {
      verses.add(getSurahNameArabic(data["surah"]));
    } else if (surahSeperator == SurahSeperator.surahNameEnglish) {
      verses.add(getSurahNameEnglish(data["surah"]));
    } else if (surahSeperator == SurahSeperator.surahNameTurkish) {
      verses.add(getSurahNameTurkish(data["surah"]));
    } else if (surahSeperator == SurahSeperator.surahNameFrench) {
      verses.add(getSurahNameFrench(data["surah"]));
    }
    for (int j = data["start"]; j <= data["end"]; j++) {
      verses.add(getVerse(data["surah"], j, verseEndSymbol: verseEndSymbol));
    }
  }
  return verses;
}