networkConnectivity static method
Check device connected network.
ConnectivityResult.bluetooth is connected network when bluetooth
parameter is true and connectivity result is ConnectivityResult.bluetooth
Implementation
static Future<bool> networkConnectivity({bool bluetooth = false}) async {
ConnectivityResult result = await connectivityResult();
if (result == ConnectivityResult.wifi ||
result == ConnectivityResult.mobile ||
result == ConnectivityResult.ethernet) {
return Future.value(true);
} else if (result == ConnectivityResult.bluetooth && bluetooth) {
return Future.value(true);
} else {
return Future.value(false);
}
}