canBeInternationallyDialled method

bool canBeInternationallyDialled(
  1. PhoneNumber number
)

Returns true if the number can be dialled from outside the region, or unknown. If the number can only be dialled from within the region, returns false. Does not check the number is a valid number. Note that, at the moment, this method does not handle short numbers (which are currently all presumed to not be diallable from outside their country).

number the phone-number for which we want to know whether it is diallable from outside the region. returns true if the number can only be dialled from within the country.

Implementation

bool canBeInternationallyDialled(PhoneNumber number) {
  String? regionCode = getRegionCodeForNumber(number);
  PhoneMetadata? metadata = getMetadataForRegion(regionCode: regionCode);
  if (metadata == null) {
    // Note numbers belonging to non-geographical entities (e.g. +800 numbers)
    // are always internationally diallable, and will be caught here.
    return true;
  }

  String nationalSignificantNumber = getNationalSignificantNumber(number);
  return !_isNumberMatchingDesc(
      nationalSignificantNumber, metadata.noInternationalDialling);
}