isSmsServiceForRegion method

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

Given a valid short number, determines whether it is an SMS service (however, nothing is implied about its validity). An SMS service is where the primary or only intended usage is to receive and/or send text messages (SMSs). This includes MMS as MMS numbers downgrade to SMS if the other party isn't MMS-capable. 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 an SMS service in the provided region, assuming the input was a valid short number

Implementation

bool isSmsServiceForRegion(PhoneNumber number, String regionDialingFrom) {
  if (!_regionDialingFromMatchesNumber(number, regionDialingFrom)) {
    return false;
  }
  PhoneMetadata? phoneMetadata =
      _getShortNumberMetadataForRegion(regionDialingFrom);
  return phoneMetadata != null &&
      _matchesPossibleNumberAndNationalNumber(
          _getNationalSignificantNumber(number), phoneMetadata.smsServices);
}