getProvinces static method

List<Province> getProvinces({
  1. int? code,
  2. String? query,
})

Gets the list of provinces.

Optionally filters by code or query.

Implementation

static List<Province> getProvinces({int? code, String? query}) {
  return _provinces.where((province) {
    final matchesCode = code == null || province.code == code;

    final normalizedQuery = query != null ? removeDiacritics(query) : null;
    final normalizedProvinceName = removeDiacritics(province.name);

    final matchesQuery = normalizedQuery == null ||
        normalizedProvinceName.contains(normalizedQuery);
    return matchesCode && matchesQuery;
  }).toList();
}