isURL property

bool get isURL

Checks if this string is a valid URL

Example:

print('https://example.com'.isURL); // true
print('invalid-url'.isURL); // false

Implementation

bool get isURL {
  try {
    final uri = Uri.parse(this);
    return uri.hasScheme && uri.hasAuthority;
  } catch (_) {
    return false;
  }
}