isPhone static method

bool isPhone(
  1. String value
)

Returns true for a valid phone number (6–15 digits, optional prefix).

Implementation

static bool isPhone(String value) {
  final String cleaned = value.trim().replaceAll(' ', '');
  final RegExp regex = RegExp(r'^\+?[0-9]{6,15}$');
  return regex.hasMatch(cleaned);
}