You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行flutter create firstapp时依赖解析长时间卡住求助

Flutter创建项目卡在依赖解析环节(首次创建耗时超2小时)

问题描述

执行命令flutter create firstapp创建项目时,卡在Resolving dependencies in firstapp...环节,首次创建已耗时2-3小时仍未完成,终端输出如下:

C:\dev>flutter create firstapp
Creating project firstapp...
Resolving dependencies in firstapp... (6:04.2s)

解决办法

  • 终止当前进程,配置国内镜像源
    这是最直接的解决方案,Flutter默认依赖源在境外,国内访问速度极慢。

    1. 关闭当前终端,终止正在运行的依赖解析进程
    2. 配置环境变量(永久生效):
      在系统环境变量中添加两个变量:
      • PUB_HOSTED_URL=https://pub.flutter-io.cn
      • FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
        或者在终端临时设置(仅当前会话有效,Windows cmd):
      set PUB_HOSTED_URL=https://pub.flutter-io.cn
      set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
      
    3. 重新执行flutter create firstapp
  • 跳过初始依赖获取,手动执行
    如果镜像源配置后还是有问题,可以先创建项目时跳过依赖下载:

    flutter create --no-pub firstapp
    

    进入项目目录后,再手动执行:

    cd firstapp
    flutter pub get
    
  • 检查网络与代理
    确保网络连接稳定,若使用代理,确认代理配置正确且能正常访问外部资源,必要时可暂时关闭代理后重试。

内容的提问来源于stack exchange,提问作者ewan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 14:32:33