Page cover

Integrate oneconnect SDK in Flutter

It will support cross-platform IOS & Android

oneconnect_flutter: ^1.0.5

OneConnect VPN is a private virtual network that has unique features and has high security. Any Developers can Create their Dream VPN App Using Our SDK and Resource, it support android and iOS

Installation

Install OneConnect library by putting this code in Pubsec.yaml

oneconnect_flutter: ^1.0.5

Import OneConnect library in your Dart file

import 'package:oneconnect_flutter/openvpn_flutter.dart';

Fetch Servers

  • Create instance of OpenVPN

OpenVPN openVPN = OpenVPN();
  • Initialize OneConnect

var oneConnectKey = "YOUR_ONECONNECT_API_KEY";
openVPN.initializeOneConnect(context, oneConnectKey); //Put BuildContext and API key

Get onceonnect api key

Save servers to list

VpnServer class contains the server id, name, flag, ovpn configuration, username, password and server type (free or pro)

Connecting to VPN

Declare variables

Select a server from the server list you have fetched earlier then save that to 'vpnConfig'

Initialize VPN engine

  • Required methods

Connect to VPN using OneConnect

For the sake of demonstration, we will use the first server (position 0) in vpnServerList and save that to 'vpnConfig'. Modify the code based on how to select servers in your project

  • Disconnect VPN

Looking for ready project, below is example project file

Last updated