diff --git a/lib/src/country_service.dart b/lib/src/country_service.dart index e862263..ddaae11 100644 --- a/lib/src/country_service.dart +++ b/lib/src/country_service.dart @@ -15,19 +15,25 @@ class CountryService { return _countries; } - ///Returns the first country that mach the given code. + ///Returns the first country that match the given code. Country? findByCode(String? code) { final uppercaseCode = code?.toUpperCase(); return _countries .firstWhereOrNull((country) => country.countryCode == uppercaseCode); } - ///Returns the first country that mach the given name. + ///Returns the first country that match the given name. Country? findByName(String? name) { return _countries.firstWhereOrNull((country) => country.name == name); } - ///Returns a list with all the countries that mach the given codes list. + ///Returns the first country that match the given phone code. + Country? findByPhoneCode(String? phoneCode) { + return _countries + .firstWhereOrNull((country) => country.phoneCode == phoneCode); + } + + ///Returns a list with all the countries that match the given codes list. List findCountriesByCode(List codes) { final List _codes = codes.map((code) => code.toUpperCase()).toList();