isConnected static method

Future<bool> isConnected()

Implementation

static Future<bool> isConnected() async {
  try {
    final result = await InternetAddress.lookup('google.com')
        .timeout(const Duration(seconds: 5));
    return result.isNotEmpty && result.first.rawAddress.isNotEmpty;
  } catch (_) {
    AutoPilotLogger.warn('No internet detected');
    return false;
  }
}