isPossibleShortNumberForRegion method

bool isPossibleShortNumberForRegion(
  1. PhoneNumber number,
  2. String regionDialingFrom
)

Check whether a short number is a possible number when dialed from the given region. This provides a more lenient check than isValidShortNumberForRegion.

number the short number to check regionDialingFrom the region from which the number is dialed returns whether the number is a possible short number

Implementation

bool isPossibleShortNumberForRegion(
    PhoneNumber number, String regionDialingFrom) {
  if (!_regionDialingFromMatchesNumber(number, regionDialingFrom)) {
    return false;
  }
  PhoneMetadata? phoneMetadata =
      _getShortNumberMetadataForRegion(regionDialingFrom);
  if (phoneMetadata == null) {
    return false;
  }
  int numberLength = _getNationalSignificantNumber(number).length;
  return phoneMetadata.generalDesc.possibleLength.contains(numberLength);
}