本文主要是介绍flutter dio使用proxyman抓包进行网络调试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
证书
wifi
手机和电脑连上同一个wifi,并且手机wifi使用代理,代理地址为电脑的ip和proxyman设置的监听端口
代码
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;}
}
使用方式
Dio dio = Dio();
ProxyUtil.useProxy(dio);
proxyIP
为电脑ip
这篇关于flutter dio使用proxyman抓包进行网络调试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!