nizwar / openvpn_flutter

A package that allow you to connect OpenVPN service with Flutter
https://pub.dev/packages/openvpn_flutter
GNU General Public License v3.0
84 stars 95 forks source link

Await Future in method "disconnect" #96

Open YukiAttano opened 9 months ago

YukiAttano commented 9 months ago

The invokeMethod("disconnect") call is not awaited. Which seems to throw if no connection is running and the method gets called. This Exception can't be catched because disconnect() does not await the invokeMethod() call.

  ///Disconnect from VPN
  void disconnect() {
    _tempDateTime = null;
    _channelControl.invokeMethod("disconnect");
    if (_vpnStatusTimer?.isActive ?? false) {
      _vpnStatusTimer?.cancel();
      _vpnStatusTimer = null;
    }
  }
bugrevealingbme commented 3 months ago

I'm getting sometime:

E/flutter ( 5968): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void de.blinkt.openvpn.core.OpenVPNService.openvpnStopped()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void de.blinkt.openvpn.core.OpenVPNService.openvpnStopped()' on a null object reference