initialize method

Future<void> initialize({
  1. String? providerBundleIdentifier,
  2. String? localizedDescription,
  3. String? groupIdentifier,
  4. dynamic lastStatus(
    1. VpnStatus status
    )?,
  5. dynamic lastStage(
    1. VPNStage status
    )?,
})

This function should be called before any usage of OpenVPN All params required for iOS, make sure you read the plugin's documentation

providerBundleIdentfier is for your Network Extension identifier

localizedDescription is for description to show in user's settings

Will return latest VPNStage

Implementation

Future<void> initialize({
  String? providerBundleIdentifier,
  String? localizedDescription,
  String? groupIdentifier,
  Function(VpnStatus status)? lastStatus,
  Function(VPNStage status)? lastStage,
}) async {
  if (Platform.isIOS) {
    assert(
        groupIdentifier != null &&
            providerBundleIdentifier != null &&
            localizedDescription != null,
        "These values are required for ios.");
  }
  onVpnStatusChanged?.call(VpnStatus.empty());
  initialized = true;
  _initializeListener();
  return _channelControl.invokeMethod("initialize", {
    "groupIdentifier": groupIdentifier,
    "providerBundleIdentifier": providerBundleIdentifier,
    "localizedDescription": localizedDescription,
  }).then((value) {
    status().then((value) => lastStatus?.call(value));
    stage().then((value) => lastStage?.call(value));
  });
}