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

You Can Now Check Transaction Stats by Date

Top 5 Key Differences between On-premises ERP and Cloud ERP solutions

Agile Movers & Shakers (1): Viktor Cessan

Web Development with Flask

Understanding SQL Queries Performance Using SQL EXPLAIN and ANALYZE

Is The Server Down? Send Automated Alerts to Your Team Using Python

A neon zig-zag arrow pointing to the bottom right

Streams vs. Sequences in Kotlin

Amazon App CS11 Error Solution 2022

Amazon App CS11 Error Solution 2022

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

Divider in Flutter

Flutter — manage permissions directly in app

How to use Flutter Time Series Charts with Firebase

The Completer class in Dart