getCountryDatasByPhone function
returns a list of country datas with a country code of
the supplied phone number. The return type is List because
many countries and territories may share the same phone code
the list will contain one PhoneCountryData at max
returns
A list of PhoneCountryData datas or an empty list
Implementation
List<PhoneCountryData> getCountryDatasByPhone(String phone) {
phone = toNumericString(
phone,
allowAllZeroes: true,
);
if (phone.isEmpty || phone.length < 11) {
return <PhoneCountryData>[];
}
var phoneCode = phone.substring(0, phone.length - 10);
return PhoneCodes.getAllCountryDatasByPhoneCode(phoneCode);
}