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.
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 🙂 ).
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
In case of no internet, we get as
In the final app, on the button click I have updated the text with mobile internet status:
Similarly, in case of no net 🙁

Gist……….
Video Demonstration :
Complete Source Code : https://github.com/AseemWangoo/flutter_programs/blob/master/InternetConnectivity.dart
P.S……………
Hello,
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.
Thanks
Thanks for the suggestion