matchSearch static method

int matchSearch({
  1. required String keyword,
  2. required List<String> criterias,
})

Implementation

static int matchSearch({required String keyword, required List<String> criterias}){
  if(keyword.isNullOrEmpty() || isNullOrEmpty(criterias)) return 0;
  int matchWeight = 0;
  List<String> splittedKeywords = keyword.toLowerCase().trim().split(RegExp(" "));
  criterias.forEach((element) {
    splittedKeywords.forEach((key) {
      if(!key.isNullOrEmpty() && contains(element, key)){
        matchWeight++;
      }
    });
  });
  return matchWeight;
}