isValidPhoneNumber static method

bool isValidPhoneNumber(
  1. String phone
)

Validates if the given string is a valid phone number. Supports international formats.

Implementation

static bool isValidPhoneNumber(String phone) {
  final regex = RegExp(r'^\+?[1-9]\d{1,14}\$');
  return regex.hasMatch(phone);
}