简体   繁体   中英

Error while making json api call in flutter

I am facing below error

Unhandled Exception: SocketException: Insecure socket connections are disallowed by platform: 111.11.111.11

while executing the below json api call to the server in flutter application

var response = await http.post(loginapiUrl, body: data);

I cannot configure https:// for my url. please provide me the solution

Add network configuration in Android and iOS respectively as you are acessing the Insecure Connections.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">secure.example.com</domain>
    </domain-config>
</network-security-config>

In respective folder add those thing inside the AndroidManifest.

For more instruction follow this.

https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM