Flutter Dev Journal(3): HTTP proxy
文章目录
When you want to setup proxy to debug network traffic as you do in developing native apps, you will find there’s no traffic comming through. The reason why this happens is that the proxy configuration in Andorid or iOS Wifi network settings don’t affect Flutter.
So we have to set up the proxy in our Flutter app. Luckly it’s just a piece of cake with the code below:
1 | class MyProxyHttpOverride extends HttpOverrides { |
Important things to know:
HttpOverrides.global
must be set before using any HTTP methods- If proxy configuration (IP or port) is changed during using, the app has to be killed and relaunched for the new configuration to take effect
- For HTTPS, certificates are loaded from the OS, same as native apps