phone static method

bool phone(
  1. String? phone
)

Implementation

static bool phone(String? phone) {
  if (phone != null && phone.isNotEmpty) {
    RegExp regExp = RegExp(r'^\(?\d{2}\)?\s?\d{5}-?\d{4}$');
    return regExp.hasMatch(phone);
  }
  return false;
}