searchCommuneByName method

List<Commune?>? searchCommuneByName(
  1. String communeName,
  2. Language language
)

Returns list of Commune object

this method takes two paramateres communeName and language (FR or AR) looks for every Commune's name that containts communeName in the country and return the result as list of Commune

Implementation

List<Commune?>? searchCommuneByName(String communeName, Language language) {
  return algeria_cites
      .where((element) {
        if (language == Language.AR) {
          return ((element['commune_name'].toString().contains(communeName)));
        } else {
          return ((element['commune_name_ascii'].toString().contains(communeName)));
        }
      })
      .map((e) => Commune(data: e))
      .toSet()
      .toList();
}