Manage Connectivity In Your Flutter App

Here is the easiest way to manage your app’s connectivity using Flutter and the Connectivity package!

Gaspard Merten
Flutter Community

--

If you have an app that interacts with the outside world, you probably want to make sure that the user is connected before executing any HTTP request!

To accomplish that, we will employ the Connectivity package developed by the Flutter team.

Photo by Thomas Jensen on Unsplash

The Connectivity Package.

This package is rather useful to manage the state of your app’s depending on its current internet connection!

There are two important methods and one getter for the Connectivity class:

  • onConnectivityChanged: returns a Stream which will allow you to know whenever the connectivity of your app changes.
  • checkConnectivity: returns the current connectivity of your app.
  • getWifiName: returns the SSID of the wifi.

Integrate The Connectivity Package In Your App.

Now what we want to do is integrate the package in our app!

What we will try to achieve here is to display a no-connection view whenever the user loses his connection!

--

--

Gaspard Merten
Flutter Community

Co-Founder & CTO @ GiveActions 🛠️ | Writer on Medium 🪶 | Flutter & Django ❤️ | Polytechnic School of Brussels 🎓| Mountain Lover 🗻