Flutter提示Bad state: Insecure HTTP is not allowed by platform

原因:IOS和Android 9.0+对非HTTPS请求做了一些限制,不能直接访问Http请求或者其他原因导致

解决办法如下:

    1.在android项目下找app->src->main->res下新建xml文件夹,然后新建network_security_config.xml文件及内容如下图:

     

Flutter提示Bad state: Insecure HTTP is not allowed by platform_第1张图片

Flutter提示Bad state: Insecure HTTP is not allowed by platform_第2张图片

 

    2.在android的清单文件(AndroidManifest.xml)的application标签内添加属性:

android:networkSecurityConfig="@xml/network_security_config"如下图:

Flutter提示Bad state: Insecure HTTP is not allowed by platform_第3张图片

    3.然后restart项目,重新运行即可。 

 

你可能感兴趣的:(android,flutter)