checkValidUrl static method

bool checkValidUrl(
  1. String url
)

Check if string is a valid URL

url - The URL string to validate Returns true if URL is valid

Implementation

static bool checkValidUrl(String url) {
  try {
    final uri = Uri.parse(url);
    return uri.hasScheme && (uri.scheme == 'http' || uri.scheme == 'https');
  } catch (e) {
    return false;
  }
}