isPhoneNumber static method

bool isPhoneNumber(
  1. String s
)

Checks if string is phone number.

Implementation

static bool isPhoneNumber(String s) {
  if (s.length > 16 || s.length < 9) {
    return false;
  } else if (s.length > 9 &&
      !ddds.contains(removeCharacters(s).substring(0, 2))) {
    return false;
  } else {
    return hasMatch(s, r'^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$');
  }
}