flutter dio使用proxyman抓包进行网络调试

证书

wifi

手机和电脑连上同一个wifi,并且手机wifi使用代理,代理地址为电脑的ip和proxyman设置的监听端口

代码

dart 复制代码
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
import 'dart:io';

class ProxyUtil {
  static String proxyIP = "";
  static String proxyPort = "9090";

  static Dio useProxy(Dio dio) {
    if (proxyIP == "") return dio;
    dio.httpClientAdapter = IOHttpClientAdapter(
      createHttpClient: () {
        final client = HttpClient();
        client.findProxy = (uri) {
          // Proxy all request to localhost:8888.
          // Be aware, the proxy should went through you running device,
          // not the host platform.
          return 'PROXY $proxyIP:$proxyPort';
        };
        client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
        return client;
      },
    );
    return dio;
  }
}

使用方式

dart 复制代码
Dio dio = Dio();
ProxyUtil.useProxy(dio);

proxyIP为电脑ip

相关推荐
火柴就是我10 小时前
flutter 之真手势冲突处理
android·flutter
Speed12310 小时前
`mockito` 的核心“打桩”规则
flutter·dart
法的空间10 小时前
Flutter JsonToDart 支持 JsonSchema
android·flutter·ios
恋猫de小郭10 小时前
Android 将强制应用使用主题图标,你怎么看?
android·前端·flutter
白帽黑客沐瑶10 小时前
【网络安全就业】信息安全专业的就业前景(非常详细)零基础入门到精通,收藏这篇就够了
网络·安全·web安全·计算机·程序员·编程·网络安全就业
玲珑Felone11 小时前
从flutter源码看其渲染机制
android·flutter
树码小子11 小时前
Java网络编程:(socket API编程:TCP协议的 socket API -- 回显程序的服务器端程序的编写)
java·网络·tcp/ip
绿箭柠檬茶13 小时前
Ubuntu 服务器配置转发网络访问
服务器·网络·ubuntu
real 113 小时前
传输层协议UDP
网络·网络协议·udp
路由侠内网穿透14 小时前
本地部署 GPS 跟踪系统 Traccar 并实现外部访问
运维·服务器·网络·windows·tcp/ip