Surah.fromJson constructor
Creates a Surah from JSON data
Implementation
factory Surah.fromJson(Map<String, dynamic> json) {
final ayatList = json['ayat'] as List<dynamic>?;
return Surah(
id: json['id'] as int,
name: json['name'] as String,
englishName: json['englishName'] as String,
revelationType: json['revelationType'] as String,
numberOfAyahs: json['numberOfAyahs'] as int,
revelationOrder: json['revelationOrder'] as int,
ayat: ayatList
?.map(
(ayahJson) => Ayah.fromJson(ayahJson as Map<String, dynamic>))
.toList() ??
[],
source:
json['source'] as String? ?? "Tanzil Project - https://tanzil.net",
);
}