haveConnectivity function

Future<bool> haveConnectivity({
  1. bool showToast = true,
})

Implementation

Future<bool> haveConnectivity({bool showToast = true}) async {
  var connection = await Connectivity().checkConnectivity();
  if (connection.isEmpty) {
    return false;
  }
  if (connection.first == ConnectivityResult.none && showToast) {
    Fluttertoast.showToast(msg: S.of().networkErrorTip);
  }
  return connection.first != ConnectivityResult.none;
}