startV2Ray method
Starts the V2Ray service with the given configuration and settings.
remark
is a string identifier for the connection.
config
is the V2Ray configuration in JSON format.
blockedApps
is an optional list of app package names to block.
bypassSubnets
is an optional list of subnets to bypass the VPN.
proxyOnly
is a boolean indicating whether to run in proxy-only mode.
notificationDisconnectButtonName
is the text for the disconnect button in notifications.
Throws an ArgumentError if the config is not valid JSON.
Returns a Future that completes when the service starts.
Implementation
Future<void> startV2Ray({
required String remark,
required String config,
List<String>? blockedApps,
List<String>? bypassSubnets,
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.startV2Ray(
remark: remark,
config: config,
blockedApps: blockedApps,
proxyOnly: proxyOnly,
bypassSubnets: bypassSubnets,
notificationDisconnectButtonName: notificationDisconnectButtonName,
);
}