Flutter
Currently, Flutter does not use the system-level proxy, so if you use Proxyman, you might not see any traffic from your Flutter Project.
The good news is that you can work around this issue by manually configuring Flutter’s HTTP client to use Proxyman as its proxy.
In general, we have to manually config the HTTP Client to proxy all traffic to Proxyman Proxy Server, which is listening at IP = localhost, port = 9090.

How to use Proxyman & Flutter

  1. 1.
    Open Proxyman -> Certificate Menu -> Install Certificate on Android -> Physical Device.
  2. 2.
    Make sure you follow all steps, except step 2: Config Wifi Proxy
For step 2:
Depending on which HTTP client you’re using, the steps will be slightly different. We will cover some popular HTTP Clients:
If you're using Android Emulator, you can use String proxy = 'localhost:9090'. Otherwise, please use String proxy = '<YOUR_LOCAL_IP>:9090' on Android Physical Devices.

Dart HTTPClient Class

1
// Make sure to replace <YOUR_LOCAL_IP> with
2
// the external IP of your computer if you're using Android.
3
// You can get the IP in the Android Setup Guide window
4
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:9090' : 'localhost:9090';
5
6
// Create a new HttpClient instance.
7
HttpClient httpClient = new HttpClient();
8
9
// Hook into the findProxy callback to set
10
// the client's proxy.
11
httpClient.findProxy = (uri) {
12
return "PROXY $proxy;";
13
};
14
15
// This is a workaround to allow Proxyman to receive
16
// SSL payloads when your app is running on Android
17
httpClient.badCertificateCallback =
18
((X509Certificate cert, String host, int port) => Platform.isAndroid);
Copied!

HTTP Package

1
// Make sure to replace <YOUR_LOCAL_IP> with
2
// the external IP of your computer if you're using Android.
3
// You can get the IP in the Android Setup Guide window
4
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:9090' : 'localhost:9090';
5
6
// Create a new HttpClient instance.
7
HttpClient httpClient = new HttpClient();
8
9
// Hook into the findProxy callback to set
10
// the client's proxy.
11
httpClient.findProxy = (uri) {
12
return "PROXY $proxy;";
13
};
14
15
// This is a workaround to allow Proxyman to receive
16
// SSL payloads when your app is running on Android.
17
httpClient.badCertificateCallback =
18
((X509Certificate cert, String host, int port) => Platform.isAndroid);
19
20
// Pass your newly instantiated HttpClient to http.IOClient.
21
IOClient myClient = IOClient(httpClient);
22
23
// Make your request as normal.
24
var response = myClient.get('/my-url');
Copied!

Dio

1
// Make sure to replace <YOUR_LOCAL_IP> with
2
// the external IP of your computer if you're using Android.
3
// You can get the IP in the Android Setup Guide window
4
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:9090' : 'localhost:9090';
5
6
// Create a new Dio instance.
7
Dio dio = Dio();
8
9
// Tap into the onHttpClientCreate callback
10
// to configure the proxy just as we did earlier.
11
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
12
// Hook into the findProxy callback to set the client's proxy.
13
client.findProxy = (url) {
14
return 'PROXY $proxy'?;
15
};
16
17
// This is a workaround to allow Proxyman to receive
18
// SSL payloads when your app is running on Android.
19
client.badCertificateCallback = (X509Certificate cert, String host, int port) => Platform.isAndroid;
20
}
Copied!

3. Continue following the Step 3, 4, and 5 to capture SSL Traffic

At this point, you can see HTTP/HTTPS Traffic on Proxyman. However, in order to intercept HTTPS Traffic, you must follow the Step 3, 4, and 5 on the Android Setup Guide.
If you haven't done it yet, you might encounter SSL Errors.

Credit & Reference

Last modified 6d ago