Updated article : https://flatteredwithflutter.com/how-to-use-stream-provider-in-flutter/

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 : https://github.com/AseemWangoo/flutter_programs/blob/master/InternetConnectivity.dart



  • Varinder

    Thanks for the tutorial, I got a problem when I use Navigator.push and move to another screen, I use the same method for checking connectivity but when I pop back I stop working on the previous screen.

    Can you please make a tutorial to check connectivity in the whole app.

Valuable comments