Skip to content

mainawycliffe/flutter_connectivity_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Demo - Connectivity Plugin Demo

Flutter Demo - Connectivity Plugin Demo

This a simple demos for using the Connectivity Plugin Demo.

The demos taps into the Stream<ConnectivityResult> provided the plugin and rebuilding the widget using the StreamBuilder everytime the connectivity status changes.

final Stream<ConnectivityResult> subscription = Connectivity().onConnectivityChanged;

And then:

StreamBuilder(
    stream: subscription,
    builder: (BuildContext context, AsyncSnapshot<ConnectivityResult> snapshot) {
        switch (snapshot.data) {
            case ConnectivityResult.mobile:
            // connection on mobile
            break;
            case ConnectivityResult.wifi:
            // connection on wifi
            break;
            default:
            // no network connection
        }
    },
)

Please note the following:

"NB: Note that on Android, this does not guarantee connection to Internet. For instance, the app might have wifi access but it might be a VPN or a hotel WiFi with no access."

About

This a simple demos for using the Connectivity Plugin Demo.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published