connectivity_wrapper icon indicating copy to clipboard operation
connectivity_wrapper copied to clipboard

Not Working on VPN

Open afzl-wtu opened this issue 2 years ago • 1 comments

If Connected to a VPN connection or Ethernet connection .. The package fails to detect if internet exists.

afzl-wtu avatar Jun 25 '23 14:06 afzl-wtu

I resolved this issue by utilizing the vpn_connection_detector package. I monitored the VPN connection stream in the following way:

vpnDetector.vpnConnectionStream.listen((state) {
  if (state == VpnConnectionState.connected) {
    setState(() {
      vpnConnected = true;
      print("VPN connected");
    });
  } else {
    setState(() {
      vpnConnected = false;
      print("VPN disconnected");
    });
  }
});

Afterward, I displayed or hide the widget based on the connection status:

return ConnectivityWidgetWrapper(
  disableInteraction: vpnConnected ? false : true,
  height: vpnConnected ? 0 : 80,
  child: widget!,
);

This might not be the most ideal practice, it helped me get the job done.

cmtboy avatar Dec 04 '23 04:12 cmtboy