isPhone function
Checks if the string is a valid phone number.
Validates a variety of phone number formats using regular expressions, covering the most common international and local phone number formats.
Supported formats include:
- International format with country code: +1234567890, +1 234 567 890
- US/North American formats: (123) 456-7890, 123-456-7890
- Format with dots: 123.456.7890
- Simple digit sequence (7-15 digits): 1234567890
Returns true if the string is a valid phone number, otherwise returns false.
Example:
isPhone('+1 234 567 8901'); // true
isPhone('(123) 456-7890'); // true
isPhone('123.456.7890'); // true
isPhone('1234567890'); // true
isPhone('not-a-number'); // false
isPhone(''); // false (empty string)
Implementation
bool isPhone(String str) => _isPhone(str);