getNumberType method

PhoneNumberType getNumberType(
  1. PhoneNumber number
)

Gets the type of a valid phone number.

number the phone number that we want to know the type. getNumberType returns the type of the phone number, or unknown if it is invalid.

Implementation

PhoneNumberType getNumberType(PhoneNumber number) {
  String? regionCode = getRegionCodeForNumber(number);

  PhoneMetadata? metadata =
      _getMetadataForRegionOrCallingCode(number.countryCode, regionCode);
  if (metadata == null) return PhoneNumberType.unknown;

  String nationalSignificantNumber = getNationalSignificantNumber(number);
  return _getNumberTypeHelper(nationalSignificantNumber, metadata);
}