当前位置:   article > 正文

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

flutter dio 抓包

证书

在这里插入图片描述

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;
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

使用方式

Dio dio = Dio();
ProxyUtil.useProxy(dio);
  • 1
  • 2

proxyIP为电脑ip

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/874455
推荐阅读
相关标签
  

闽ICP备14008679号