isPossibleShortNumber method

bool isPossibleShortNumber(
  1. PhoneNumber number
)

Check whether a short number is a possible number. If a country calling code is shared by multiple regions, this returns true if it's possible in any of them. This provides a more lenient check than isValidShortNumber. See isPossibleShortNumberForRegion(PhoneNumber, String) for details.

number the short number to check returns whether the number is a possible short number

Implementation

bool isPossibleShortNumber(PhoneNumber number) {
  List<String> regionCodes =
      _getRegionCodesForCountryCode(number.countryCode);
  int shortNumberLength = _getNationalSignificantNumber(number).length;
  for (String region in regionCodes) {
    PhoneMetadata? phoneMetadata = _getShortNumberMetadataForRegion(region);
    if (phoneMetadata == null) {
      continue;
    }
    if (phoneMetadata.generalDesc.possibleLength
        .contains(shortNumberLength)) {
      return true;
    }
  }
  return false;
}