loadSurahs static method

Future<List<SurahNameInfo>> loadSurahs()

Returns all 114 surah name entries (cached after first call).

Implementation

static Future<List<SurahNameInfo>> loadSurahs() async {
  if (_cachedSurahs != null) return _cachedSurahs!;

  final decoded = await _loadGzippedJson(_surahsGzPath);
  if (decoded is! Map) {
    throw const FormatException('surahs_name.json must be a JSON Map');
  }

  final data = decoded['data'];
  if (data is! Map || data['surahs'] is! List) {
    throw const FormatException('surahs_name.json missing data.surahs');
  }

  _cachedSurahs = (data['surahs'] as List)
      .map((e) => SurahNameInfo.fromJson(Map<String, dynamic>.from(e as Map)))
      .toList();
  return _cachedSurahs!;
}