connectsToEmergencyNumber method

bool connectsToEmergencyNumber(
  1. String number,
  2. String regionCode
)

Returns true if the given number, exactly as dialed, might be used to connect to an emergency service in the given region.

This method accepts a string, rather than a PhoneNumber, because it needs to distinguish cases such as "+1 911" and "911", where the former may not connect to an emergency service in all cases but the latter would. This method takes into account cases where the number might contain formatting, or might have additional digits appended (when it is okay to do that in the specified region).

number the phone number to test regionCode the region where the phone number is being dialed returns whether the number might be used to connect to an emergency service in the given region

Implementation

bool connectsToEmergencyNumber(String number, String regionCode) {
  return _matchesEmergencyNumberHelper(
      number, regionCode, true /* allows prefix match */);
}