exactMatch property

Surah? get exactMatch

Get the first exact match (if any)

Implementation

Surah? get exactMatch {
  final lowerSearchTerm = searchTerm.toLowerCase();

  // Try exact English name match first
  for (final surah in results) {
    if (surah.englishName.toLowerCase() == lowerSearchTerm) {
      return surah;
    }
  }

  // Try exact Arabic name match
  for (final surah in results) {
    if (surah.name == searchTerm) {
      return surah;
    }
  }

  return null;
}