phoneValidatorNullable static method

String? phoneValidatorNullable(
  1. String? value
)

Implementation

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