JuzResult.fromJson constructor

JuzResult.fromJson(
  1. Map<String, dynamic> json
)

Creates a JuzResult from JSON data

Implementation

factory JuzResult.fromJson(Map<String, dynamic> json) {
  final ayatList = json['ayat'] as List<dynamic>;

  return JuzResult(
    juz: json['juz'] as int,
    totalAyat: json['totalAyat'] as int,
    ayat: ayatList
        .map((ayahJson) =>
            AyahWithSurah.fromJson(ayahJson as Map<String, dynamic>))
        .toList(),
    source:
        json['source'] as String? ?? "Tanzil Project - https://tanzil.net",
  );
}