setSystemProxy static method

Future<bool> setSystemProxy(
  1. Proxy proxy
)

Sets the system proxy on Android

This requires root access or ADB permissions Returns true if successful, false otherwise

Implementation

static Future<bool> setSystemProxy(Proxy proxy) async {
  if (!isSupported) {
    return false;
  }

  try {
    final result = await _channel.invokeMethod('setSystemProxy', {
      'host': proxy.ip,
      'port': proxy.port.toString(),
    });
    return result == true;
  } catch (e) {
    // Use a proper logging mechanism in production
    if (kDebugMode) {
      print('Error setting system proxy: $e');
    }
    return false;
  }
}