setProxy method

void setProxy({
  1. required String ip,
  2. String port = '8888',
  3. bool enable = false,
})

proxy all request to localhost:8888

Implementation

void setProxy({required String ip, String port = '8888', bool enable = false}) {
  if (enable) {
    (_dio?.httpClientAdapter as IOHttpClientAdapter).createHttpClient = () {
      HttpClient client = HttpClient();
      client.findProxy = (uri) {
        return 'PROXY $ip:$port';
      };
      client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
      return client;
    };
  }
}