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

相关推荐

  1. 网络工具tcpdump的使用

    2024-01-01 22:06:01       22 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-01 22:06:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-01 22:06:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-01 22:06:01       82 阅读
  4. Python语言-面向对象

    2024-01-01 22:06:01       91 阅读

热门阅读

  1. Linux:20个linux常用命令

    2024-01-01 22:06:01       60 阅读
  2. js获取某天日期

    2024-01-01 22:06:01       55 阅读
  3. 国内低代码平台介绍及优势盘点

    2024-01-01 22:06:01       48 阅读
  4. 微服务(8)

    2024-01-01 22:06:01       56 阅读
  5. Golang标准库sync的使用

    2024-01-01 22:06:01       54 阅读
  6. 源码解析:mybatis调用链之获取sqlSession

    2024-01-01 22:06:01       59 阅读