isValidUrl static method

bool isValidUrl(
  1. String url
)

Implementation

static bool isValidUrl(String url) {

  // Regular expression pattern for URL validation
  const pattern = r'^https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,}$';
  final regex = RegExp(pattern);
  return regex.hasMatch(url);
}