isNetworkAvailable function

Future<bool> isNetworkAvailable()

Checks if the network is available. Returns true if connected to the internet, otherwise false.

Implementation

Future<bool> isNetworkAvailable() async {
  final bool isConnected =
      await InternetConnectionChecker.instance.hasConnection;
  if (isConnected) {
    return true;
  } else {
    return false;
  }
}