A Flutter plugin for handling
REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.
In order to use this plugin, add dependency in the
cross_connectivity: git: url: https://github.com/marchdev-tk/cross_connectivity
Add an import to dart file:
This plugin provides two streams:
isConnectedthat shows whether the device is
REALLYconnected to the network or not.
onConnectivityChangedthat it will not let you know about state of the
REALnetwork connection. It only shows connectivity state.
one time check could be used following methods:
checkConnection()that is working like
isConnected, but returns
checkConnectivity()that is working like
onConnectivityChanged, but returns
As an addition there are more methods (they are working only on Android/iOS/macOS):
getWifiName()- Obtains the wifi name (SSID) of the connected network.
getWifiBSSID()- Obtains the wifi BSSID of the connected network.
getWifiIP()- Obtains the IP address of the connected wifi network.
As an alteration to funcitonal approach could be used
ConnectivityBuilder widget as follows:
ConnectivityBuilder( builder: (context, isConnected, status) => Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Icon( isConnected == true ? Icons.signal_wifi_4_bar : Icons.signal_wifi_off, color: isConnected == true ? Colors.green : Colors.red, ), const SizedBox(width: 8), Text( '$status', style: TextStyle( color: status != ConnectivityStatus.none ? Colors.green : Colors.red, ), ), ], ), )
Feature requests and Bug reports
Feel free to post a feature requests or report a bug here.