checkForInternetConnection function

dynamic checkForInternetConnection({
  1. required ConnectionListener listener,
})

Implementation

checkForInternetConnection({required ConnectionListener listener}) async {
  try {
    final result = await InternetAddress.lookup('github.com');
    if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
      listener.onResponse(true);
    }
  } on SocketException catch (_) {
    listener.onResponse(false);
  }
}