Flutter问题汇总

1、Building flutter tool...问题

2、flutter pub get卡死

网络问题导致:

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

3、Waiting for another flutter command to release the startup lock...

等待另一个flutter命令释放启动锁,如果想终止上一个命令锁:

sudo kill $(ps aux | grep flutter | grep -v grep  | awk '{print $2}')

4、Finished with error: Failed to establish connection with the application instance in Chrome.

This can happen if the websocket connection used by the web tooling is unable to correctly establish a connection, for example due to a firewall.

解决:127.0.0.1 localhost

image.png

5、Exception: Invalid image data

图片数据无效,检查url是否是有效的jpg下载地址

Image.network(
              imgList[index]["url"],
              fit: BoxFit.fill,
            );

6、Bad state: Insecure HTTP is not allowed by platform:http://

IOS 和 Android 9.0 对网络请求做了一些限制,不能直接访问 Http 域名的地址

  • android解决
<application
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true"//加这一行
        android:networkSecurityConfig="@xml/network_security"
<?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>

network_secturity
  • IOS解决
<key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
info.plist

7、Automatically assigning platform iOS with version 9.0 on target Runner

ios/Podfile文件增加平台配置

 platform :ios, '9.0'
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容