flutter中从网络中加载图片的大坑!!!加粗样式
flutter报错 : DioError [DioErrorType.DEFAULT]:Bad State : Insecure HTTP is not allowed by platform
原因是IOS和Android 9.0对网络请求做了一些限制,不能直接访问http域名的地址
解决:通过配置允许不加密的请求
找到项目中的
安卓设备的处理方式
android/src/main/AndroidManifest.xml
```xml
<application
android:label="untitled"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
<!--以下两句是加的-->
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
>
在main/res目录中新建一个xml目录 在xml目录添加network_security_config.xml文件
<?xml version="1.0" encoding="utf-8" ?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system"></certificates>
</trust-anchors>
</base-config>
</network-security-config>
IOS解决
ios/Runner/info.plist文件,找到最后面的</dict>
在</dict>
之前添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>