phoneOrEmailValidation method
Implementation
String? phoneOrEmailValidation(String? value) {
if (value == null || value.isEmpty) {
return 'Please enter email or phone number';
}
bool isEmail = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value);
bool isPhone = RegExp(r'^\+?[\d\s-]{10,}$').hasMatch(value);
if (!isEmail && !isPhone) {
return 'Please enter a valid email or phone number';
}
return null;
}