phoneValidator static method

String? phoneValidator(
  1. String? phoneNumber
)

Implementation

static String? phoneValidator(String? phoneNumber) {
  if (phoneNumber == null) return 'Please enter mobile number';
  String patttern = r'(^(?:[+0]9)?[0-9]{10,12}$)';
  RegExp regExp = RegExp(patttern);
  if (phoneNumber.isEmpty) {
    return 'Please enter mobile number';
  } else if (!regExp.hasMatch(phoneNumber)) {
    return 'Please enter valid mobile number';
  }
  return null;
}