isValidUrl property

bool get isValidUrl

Returns true if the string is a valid URL format. Note: This is a basic check. For robust validation, consider a dedicated package.

Implementation

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