isCarrierSpecificForRegion method
Given a valid short number, determines whether it is carrier-specific when dialed from the given region (however, nothing is implied about its validity). Carrier-specific numbers may connect to a different end-point, or not connect at all, depending on the user's carrier. If it is important that the number is valid, then its validity must first be checked using isValidShortNumber or isValidShortNumberForRegion. Returns false if the number doesn't match the region provided.
number
the valid short number to check
regionDialingFrom
the region from which the number is dialed
returns whether the short number is carrier-specific in the provided region,
assuming the input was a valid short number
Implementation
bool isCarrierSpecificForRegion(
PhoneNumber number, String regionDialingFrom) {
if (!_regionDialingFromMatchesNumber(number, regionDialingFrom)) {
return false;
}
String nationalNumber = _getNationalSignificantNumber(number);
PhoneMetadata? phoneMetadata =
_getShortNumberMetadataForRegion(regionDialingFrom);
return (phoneMetadata != null) &&
(_matchesPossibleNumberAndNationalNumber(
nationalNumber, phoneMetadata.carrierSpecific));
}