isValidPhone static method

bool isValidPhone(
  1. String value
)

Check if a String is a valid phone number

Implementation

static bool isValidPhone(String value) {
  value = value.replaceAll(" ", '');
  value = value.replaceAll("-", '');
  value = value.replaceAll("+", '');

  String pattern = r'(^(?:[+0]9)?[0-9]{10,12}$)';
  bool valid = RegExp(pattern).hasMatch(value);
  return valid;
}