checkNetwork static method

Future<bool> checkNetwork()

Verifies if there is network connectivity

Implementation

static Future<bool> checkNetwork() async {
  try {
    final result = await InternetAddress.lookup('google.com');
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      return true;
    }
    return false;
  } on SocketException catch (_) {
    return false;
  }
}