isValidUrl property
bool
isValidUrl
Determines whether the string is a valid URL.
Example:
print('https://example.com'.isValidUrl); // Output: true
print('example.com'.isValidUrl); // Output: false
Implementation
bool get isValidUrl => RegExp(r'^(https?:\/\/)?'
r'([\w-]+(\.[\w-]+)+)'
r'([\/\w -]*)'
r'(\?[\w- ;,./?%&=]*)?'
r'(#[\w-]*)?$')
.hasMatch(this);