isValid static method

bool isValid(
  1. String? url
)

Validates if a string is a valid URL

Example:

UrlUtils.isValid('https://example.com'); // true

Implementation

static bool isValid(String? url) {
  if (url == null || url.isEmpty) return false;
  try {
    final uri = Uri.parse(url);
    return uri.hasScheme && (uri.scheme == 'http' || uri.scheme == 'https');
  } catch (_) {
    return false;
  }
}