flutter 2.X报错 Bad state: Insecure HTTP is not allowed by platform:
flutter2.x开发遇到的问题 Bad state: Insecure HTTP is not allowed by platform:
翻译过来就是:错误状态:平台不允许不安全的HTTP:
产生原因:IOS 和 Android 9.0 对网络请求做了一些限制,不能直接访问 Http 域名的地址。
解决方案如下:
Android 配置
找到下图位置,添加这两行代码
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"


添加 network_security_config.xml 文件,没有这个文件就创建一个,注意一下路径哦
android\app\src\main\res\xml\network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>

IOS 配置
找到 ios/Runner/Info.plist,添加关于 NSAppTransportSecurity NSAllowsArbitraryLoads 的配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>

搞完以后,重启项目!!重启重启重启重启!重启解决一切问题!!!!
下面的可能用不到,一般上面的都可以解决问题了哦~~~
备注:网上还查资料看到network_security_config.xml有其他配置办法
此办法参考链接:https://www.cnblogs.com/sea-stream/p/13908198.html
补充如下
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
or
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!-- 配置7.0抓包--start -->
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user"/>
</trust-anchors>
</debug-overrides>
<!-- 配置7.0抓包--end -->
<!-- 配置9.0明文请求--start -->
<base-config cleartextTrafficPermitted="true" />
<!-- 配置9.0明文请求--end -->
</network-security-config>
flutter 2.X报错 Bad state: Insecure HTTP is not allowed by platform:的更多相关文章
- pip安装报错:is not a supported wheel on this platform
可能的原因1:安装的不是对应python版本的库,下载的库名中cp27代表python2.7,其它同理. 可能的原因2:这个是我遇到的情况(下载的是对应版本的库,然后仍然提示不支持当前平台) 我下载到 ...
- Python——pip安装报错:is not a supported wheel on this platform
pip安装报错:is not a supported wheel on this platform 可能的原因1:安装的不是对应python版本的库,下载的库名中cp35代表python3.5,其它同 ...
- 安装Tensorflow过程pip安装报错:is not a supported wheel on this platform
安装Tensorflow过程pip安装报错:is not a supported wheel on this platform 通过pip安装wheel镜像时,安装指令为: pip install - ...
- Flutter配置环境报错“PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”
背景:最近看了很多Flutter漂亮的项目,想要尝试一下.所有环境都搭建好之后,按照文档一步一步配置(抄袭),但始终报如下图错误. PKIX path building failed: sun.sec ...
- Flutter使用SingleTickerProviderStateMixin报错
最近在学习开发Flutter应用项目,在创建tabbar和tabview后,进行网络请求后显示顶部tab标签,设置TabController,并使class类实现SingleTickerProvide ...
- Mysql数据库连接报错!1130:host XXX is not allowed to connect to this mysql server
我猜想是可能是连接的用户权限问题.结果这样子操作mysql库,可以解决此问题.在本机登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost” ...
- 远程连接mysql报错【1130 -host 'localhost' is not allowed to connect to this mysql server】
远程连接mysql时包如下错误: 1130 -host 'localhost' is not allowed to connect to this mysql server 解决办法 本地用root账 ...
- MySQL报错:Packets larger than max_allowed_packet are not allowed 的解决方案
在导大容量数据特别是CLOB数据时,可能会出现异常:“Packets larger than max_allowed_packet are not allowed”. 这是由于MySQL数据库有一个系 ...
- mysql 报错 Packets larger than max_allowed_packet are not allowed
登录 mysql, 执行命令 : show variables like '%max_allowed_packet%' 重新设置: set global max_allowed_packet = 1 ...
- mysql报错:1130 -host 'localhost' is not allowed to connect to this mysql server
错误提示:1130 -host 'localhost' is not allowed to connect to this mysql server 原因:手贱把mysql数据库系统中mysql数据库 ...
随机推荐
- 六、模型层(ORM)
六.模型层(ORM) Django中内嵌了ORM框架,不需要直接编写SQL语句进行数据库操作,而是通过定义模型类,操作模型类来完成对数据库中表的增删改查和创建等操作. O是object,也就类对象的意 ...
- JMETER与BeanShell
变量 Beanshell应用自定义变量有两种方法: #第一种方法,使用${key}格式,但是需要注意这是用应用的变量是没有定义数据类型的 #log.info(String Key)只能打印字符串,所以 ...
- cordon节点,drain驱逐节点,delete 节点
目录 一.系统环境 二.前言 三.cordon节点 3.1 cordon节点概览 3.2 cordon节点 3.3 uncordon节点 四.drain节点 4.1 drain节点概览 4.2 dra ...
- 在 .NET 7上使用 WASM 和 WASI
WebAssembly(WASM)和WebAssembly System Interface(WASI)为开发人员开辟了新的世界..NET 开发人员在 Blazor WebAssembly 发布时熟悉 ...
- VP记录
预计在最后的日子里适量VP 简单记录一下 CF 1037 Link 上来秒了ABCD,很快啊 A是二进制拆分,B是一眼贪心,C是一个非常简单且好写的dp D把边遍历顺序按照所需的bfs顺序排序,最后比 ...
- <一>类,对象,this指针
C++ 类:实体的抽象类型 实体(属性,行为) ->ADT(abstract data type) 类(属性->成员变量,行为->成员方法) OOP语言4大特征 抽象 封装/隐藏(通 ...
- 从0到1搭建redis6.0.7续更~
"心有所向,日复一日,必有精进" 前言: 想必大家看完我之前写的搭建redis服务器,大家都已经把redis搭建起来了吧如果没有搭建起来的小可爱请移步这里哦从0到1搭建redis6 ...
- 详解从浏览器地址栏输入URL到页面显示的步骤
版本1(基础版本) 步骤1:浏览器根据请求的 URL 交给 DNS 域名解析,找到真实 IP ,向服务器发起请求: 步骤2:服务器交给后台处理完成后返回数据,浏览器接收⽂件( HTML.JS.CSS ...
- Bitmap和byte[]的相互转换
/// <summary> /// 将Bitmap转换为字节数组 /// </summary> /// <param name="width"> ...
- webrtc编译,不使用内置boringssl,使用openssl的
前言 在项目开发过程中,会遇到使用https.TLS.DTLS等场景,这些第三方库一般会使用openssl作为加密套件.例如,qt中加密套件就会使用openssl,但是webrtc会默认使用borin ...