在Dio client设置如下代码:
client.findProxy = (uri) {
//charles设置的代理 (proxy)
return "PROXY 192.168.150.61:8889";
};
完整DioUtil:
import 'package:dio/dio.dart';
class DioUtils {
/// global dio object
static Dio dio;
static const String BASE_URL =
'http://mock.apistub.cn/user/shitian2274/demo/';
static const int CONNECT_TIMEOUT = 10000;
static const int RECEIVE_TIMEOUT = 3000;
/// http request methods
static const String GET = 'get';
static const String POST = 'post';
static const String PUT = 'put';
static const String PATCH = 'patch';
static const String DELETE = 'delete';
///Get
static void getHttp() async {
try {
Response response = await Dio().get("http://www.google.cn");
print("response$response"