Flutter debug 模式下https网络抓包

本文使用的是dio网络框架

使用Fiddler或者Charles设置代理抓包。

static void initHttp() {
if (dio == null) {
dio = Dio();
}
bool inProduction = bool.fromEnvironment(“dart.vm.product”);
if (inProduction) {
return;
}
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
client.findProxy = (uri) {
return “PROXY 192.168.1.100:8888”;
};
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
return true;
};
};
}