phoneValidator static method

String? phoneValidator(
  1. String? value
)

Implementation

static String? phoneValidator(String? value) {
  final phone = (value ?? "").trim();
  if (phone.isEmpty) {
    return "Enter phone number";
  }
  if (!RegExp(r'^\+[1-9]\d{7,14}$').hasMatch(phone)) {
    return "Enter a valid phone number (e.g. +919998887777)";
  }
  return null;
}