isPhone property

bool get isPhone

Checks if the string is a valid phone number.

Validates phone numbers with optional country code, spaces, hyphens, and parentheses. Supports international formats like +1 (123) 456-7890 as well as simple formats like 1234567890.

Implementation

bool get isPhone => regex(r'^\+?[\d\s\(\)\-]{10,20}$');