findCountriesByCode method

List<Country> findCountriesByCode(
  1. List<String> codes
)

Returns a list with all the countries that mach the given codes list.

Implementation

List<Country> findCountriesByCode(List<String> codes) {
  final List<String> _codes =
      codes.map((code) => code.toUpperCase()).toList();
  final List<Country> countries = [];
  for (final code in _codes) {
    final Country? country = findByCode(code);
    if (country != null) {
      countries.add(country);
    }
  }
  return countries;
}