searchWordsInTranslation function
Map
searchWordsInTranslation(
- List<
String> words, { - Translation translation = Translation.enSaheeh,
Takes a list of words words
and translation
(optional) and returns a map containing no. of occurences and result of the word search in the traslation
Implementation
Map searchWordsInTranslation(List<String> words,
{Translation translation = Translation.enSaheeh}) {
var translationText = enSaheeh;
switch (translation) {
case Translation.enSaheeh:
translationText = enSaheeh;
break;
case Translation.trSaheeh:
translationText = trSaheeh;
break;
case Translation.mlAbdulHameed:
translationText = mlAbdulHameed;
break;
case Translation.frHamidullah:
translationText = frHamidullah;
break;
default:
translationText = enSaheeh;
}
List<Map> result = [];
for (var i in translationText) {
bool exist = false;
for (var word in words) {
if (i['content']
.toString()
.toLowerCase()
.contains(word.toString().toLowerCase())) {
exist = true;
}
}
if (exist) {
result.add({"surah": i["surah_number"], "verse": i["verse_number"]});
}
}
return {"occurences": result.length, "result": result};
}