Skip to content

Instantly share code, notes, and snippets.

@miguelpruivo
Created April 10, 2019 11:31
Show Gist options
  • Save miguelpruivo/2830b2ec41469cf8497f05255f90b454 to your computer and use it in GitHub Desktop.
Save miguelpruivo/2830b2ec41469cf8497f05255f90b454 to your computer and use it in GitHub Desktop.
Check connection
Future<bool> checkConnection() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
return true;
}
} on SocketException catch (_) {}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment