isValidUrl property
bool
get
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'(localhost|[\w-]+(\.[\w-]+)+)'
r'(:\d+)?'
r'(/[\/\w \.-]*)?'
r'(\?[\w- ;,./?%&=]*)?'
r'(#[\w-]*)?$')
.hasMatch(this);