An open API service indexing awesome lists of open source software.

https://github.com/mainawycliffe/flutter_connectivity_demo

This a simple demos for using the Connectivity Plugin Demo.
https://github.com/mainawycliffe/flutter_connectivity_demo

connectivity flutter flutter-plugins

Last synced: 4 months ago
JSON representation

This a simple demos for using the Connectivity Plugin Demo.

Awesome Lists containing this project

README

          

# Flutter Demo - Connectivity Plugin Demo

![Flutter Demo - Connectivity Plugin Demo](demo/demo.gif)

This a simple demos for using the [Connectivity Plugin Demo](https://pub.dev/packages/connectivity).

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

```dart
final Stream subscription = Connectivity().onConnectivityChanged;
```

And then:

```dart
StreamBuilder(
stream: subscription,
builder: (BuildContext context, AsyncSnapshot 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."