doesConnectTo method

  1. @override
Future<bool> doesConnectTo(
  1. String address
)
override

Implementation

@override
Future<bool> doesConnectTo(String address) async {
  try {
    final url = address.startsWith("http") || address.startsWith("/")
        ? address
        : "https://$address";
    final request = await HttpRequest.request(
      url,
      requestHeaders: {
        'Cache-Control': 'no-cache',
        'Pragma': 'no-cache',
      },
    );

    return (request.status ?? 0) < 400;
  } catch (_) {
    return false;
  }
}