checkConnectivity static method
Future<ConnectivityResult>
checkConnectivity(
)
Implementation
static Future<ConnectivityResult> checkConnectivity() async{
var connectivityResult = await Connectivity().checkConnectivity();
if (connectivityResult.contains(ConnectivityResult.mobile)) {
// I am connected to a mobile network.
logNUI(_MODULE, "Device is connected to a mobile network");
return ConnectivityResult.mobile;
} else if (connectivityResult.contains(ConnectivityResult.wifi)) {
// I am connected to a wifi network.
logNUI(_MODULE, "Device is connected to a wifi network");
return ConnectivityResult.wifi;
} else if (connectivityResult.contains(ConnectivityResult.vpn)) {
// I am connected to a VPN network.
logNUI(_MODULE, "Device is connected to a VPN network");
return ConnectivityResult.vpn;
} else {
// No connectivity
logNUI(_MODULE, "Device is not connected to any network");
}
return connectivityResult.first;
}