isUrlAvailable static method

Future<bool> isUrlAvailable(
  1. String host,
  2. String path
)

Implementation

static Future<bool> isUrlAvailable(String host, String path) async {

  http.Client client = http.Client();

  try{

    final http.Response response = await client.get(
        Uri.https(host, path)
    );

    if(response.statusCode == 200){
      print('URL AVAILABLE!');
      return true;
    }

  } catch(e){

    print('URL UNAVAILABLE!');
    return false;

  } finally{
    client.close();
  }

  return false;

}