hasNetworkConnection static method

Future<bool> hasNetworkConnection()

Check if the device has network connection

Implementation

static Future<bool> hasNetworkConnection() async {
  final List<ConnectivityResult> connectivityResult =
      await Connectivity().checkConnectivity();
  if (connectivityResult.contains(ConnectivityResult.wifi)) {
    return true;
  } else if (connectivityResult.contains(ConnectivityResult.mobile)) {
    return true;
  }
  return false;
}