Flutter — How to Check Internet Connection

Check whether the device have internet connectivity.

Plugin: connectivity

One time check

Future<bool> hasNetwork() async {
try {
final result = await InternetAddress.lookup('example.com');
return result.isNotEmpty && result[0].rawAddress.isNotEmpty;
} on SocketException catch (_) {

--

--

--

Flutter and Native Android developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Backtracking, Pitfalls, and Me

6 Reasons Why You Should Be Microsoft Azure Certified

6 Reasons Why You Should Be Microsoft Azure Certified

C #: from medium to advance level [Access modifier and Properties (Part II)]

Justifying Faster Computers

Save OpenGL Rendering Result As A Video

My first online hackathon

Customize or Extend Python Third-Party Modules Using Partial Function

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Flutter Developer

Flutter Developer

Flutter and Native Android developer

More from Medium

Flutter Joystick

DartUP 2021: Two days, 3000 participants on the Dart side

Becoming a Pro from Noob Flutter Developer|UI|Dart

How to Disable the Default Widget Splash Effect in Flutter?