openvpn_flutter 1.0.1 copy "openvpn_flutter: ^1.0.1" to clipboard
openvpn_flutter: ^1.0.1 copied to clipboard

retractedoutdated

Connect OpenVPN service with Flutter

Connect OpenVPN service with Flutter, Issues and PRs are very welcome!

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  openvpn_flutter: ^1.0.1

Run the command and you're ready to go

$ flutter pub get

Android Installation #

No need to setup anything on android 🤭

iOS Installation #

1. Add Capabillity #

Add 2 capabillity on Runner's Target, App Groups and Network Extensions, Look at the image below to get clearer details

2. Add New Target #

Click + button on bottom left, Choose NETWORK EXTENSION, and follow instruction's image bellow

Add Capabillity on VPNExtension, Do it same like Runner's Capabillitiy

All done, lets go back to flutter

Recipe #

Initialize #

Before start, you have to initialize the OpenVPN plugin.

    late OpenVPN openvpn;

    @override
    void initState() {
        openvpn = OpenVPN(onVpnStatusChanged: _onVpnStatusChanged, onVpnStageChanged: _onVpnStageChanged);
        openvpn.initialize(
            groupIdentifier: "GROUP_IDENTIFIER", ///Example 'group.com.laskarmedia.vpn'
            providerBundleIdentifier: "NETWORK_EXTENSION_IDENTIFIER", ///Example 'id.laskarmedia.openvpnFlutterExample.VPNExtension'
            localizedDescription: "LOCALIZED_DESCRIPTION" ///Example 'Laskarmedia VPN'
        );
    }

    void _onVpnStatusChanged(VPNStatus? vpnStatus){
        setState((){
            this.status = vpnStatus;
        });
    }

    void _onVpnStageChanged(VPNStage? stage){
        setState((){
            this.stage = stage;
        });
    }

Connect to VPN #

    void connect(){
        openvpn.connect(config, name, username: username, password: password, bypassPackages: [], certIsRequired: false);
    }

Disconnect #

    void disconnect(){
        openvpn.disconnect();
    }

Publishing to Play Store and App Store #

Android #

  1. You can use appbundle to publish the app

iOS #

  1. View Apple Guidelines Relating to VPN
  2. This plugin DOES use Encryption BUT, It uses Exempt Encryptions

Love my work? #

☕️ ☕️ ☕️