phone static method

String? phone(
  1. String? value, [
  2. String? message
])

Phone number

Implementation

static String? phone(String? value, [String? message]) {
  if (value == null || value.isEmpty) return null;
  final regex = RegExp(r'^\+?[\d\s\-\(\)]{9,}$');
  if (!regex.hasMatch(value)) {
    return message ?? 'Please enter a valid phone number';
  }
  return null;
}