isNetworkAvailable function

Future<bool> isNetworkAvailable()

判断设备是否连接网络

Implementation

Future<bool> isNetworkAvailable() async {
  var connectivityResult = await Connectivity().checkConnectivity();
  return !connectivityResult.contains(ConnectivityResult.none);
}