Created
April 10, 2019 11:31
-
-
Save miguelpruivo/2830b2ec41469cf8497f05255f90b454 to your computer and use it in GitHub Desktop.
Check connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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