checkInternetConnection static method

Future<bool?> checkInternetConnection()

Implementation

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