startVless method

Future<void> startVless({
  1. required String remark,
  2. required String config,
  3. List<String>? blockedApps,
  4. List<String>? bypassSubnets,
  5. List<String>? dnsServers,
  6. bool proxyOnly = false,
  7. String notificationDisconnectButtonName = "DISCONNECT",
})

Start FlutterVless service.

config:

FlutterVless Config (json)

blockedApps:

Apps that won't go through the VPN tunnel.

Contains a list of package names.

specifically for Android.

For iOS, please use blockedDomains instead, in example folder.

bypassSubnets:

[Default = 0.0.0.0/0]

Add at least one route if you want the system to send traffic through the VPN interface.

Routes filter by destination addresses.

To accept all traffic, set an open route such as 0.0.0.0/0 or ::/0.

proxyOnly:

If it is true, only the FlutterVless proxy will be executed,

and the VPN tunnel will not be executed.

dnsServers:

Custom DNS servers for the VPN tunnel.

If null, defaults to "8.8.8.8", "114.114.114.114".

Example: "94.140.14.14", "94.140.15.15" for AdGuard DNS (ad-blocking)

Implementation

Future<void> startVless({
  required String remark,
  required String config,
  List<String>? blockedApps,
  List<String>? bypassSubnets,
  List<String>? dnsServers,
  bool proxyOnly = false,
  String notificationDisconnectButtonName = "DISCONNECT",
}) async {
  try {
    if (jsonDecode(config) == null) {
      throw ArgumentError('The provided string is not valid JSON');
    }
  } catch (_) {
    throw ArgumentError('The provided string is not valid JSON');
  }

  await FlutterV2rayPlatform.instance.startVless(
    remark: remark,
    config: config,
    blockedApps: blockedApps,
    proxyOnly: proxyOnly,
    bypassSubnets: bypassSubnets,
    dnsServers: dnsServers,
    notificationDisconnectButtonName: notificationDisconnectButtonName,
  );
}