Internet connectivity in Flutter

Updated article :

Recently, I wrote a program related to the internet connectivity in flutter. I used a package from flutter named as “connectivity”.

Added connectivity: ^0.3.0 to pubspec.yaml.

Connectivity Package

Next, we need to import the packages in the dart file.

import ‘package:connectivity/connectivity.dart’;

Now, we need to use the Connectivity class from this package. (Don’t worry below I have attached the program 🙂 ).

Connectivity package

The _connectionSubscription is a stream that listens for the internet connections(wifi or mobile data) in the mobile.


In the _connectionStatus, we get the final output, for instance are we connected to wifi or mobile data. I have attached a log file from the program below

Mobile Network

In case of no internet, we get as

Without internet

In the final app, on the button click I have updated the text with mobile internet status:

Button click on with internet

Similarly, in case of no net 🙁

Button click with no internet.
Button click with no internet.


Video Demonstration :

Complete Source Code :