Created
June 25, 2020 02:43
-
-
Save mhmzdev/49694dab934e3f329dc3a92c7f0d692e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SurahsList { | |
final List<Surah> surahs; | |
SurahsList({this.surahs}); | |
factory SurahsList.fromJSON(Map<String, dynamic> json) { | |
Iterable surahlist = json['data']['surahs']; | |
List<Surah> surahsList = surahlist.map((i) => Surah.fromJSON(i)).toList(); | |
return SurahsList(surahs: surahsList); | |
} | |
} | |
class Surah { | |
final int number; | |
final String name; | |
final String englishName; | |
final String englishNameTranslation; | |
final List<Ayat> ayahs; | |
Surah( | |
{this.number, | |
this.name, | |
this.ayahs, | |
this.englishName, | |
this.englishNameTranslation}); | |
factory Surah.fromJSON(Map<String, dynamic> json) { | |
Iterable ayahs = json['ayahs']; | |
List<Ayat> ayahsList = ayahs.map((e) => Ayat.fromJSON((e))).toList(); | |
return Surah( | |
name: json['name'], | |
number: json['number'], | |
englishName: json['englishName'], | |
englishNameTranslation: json['englishNameTranslation'], | |
ayahs: ayahsList); | |
} | |
} | |
class Ayat { | |
final String text; | |
final int number; | |
Ayat({this.text, this.number}); | |
factory Ayat.fromJSON(Map<String, dynamic> json) { | |
return Ayat(text: json['text'], number: json['numberInSurah']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment