美文网首页
Flutter卡在Running "flutter packag

Flutter卡在Running "flutter packag

作者: 贝勒老爷 | 来源:发表于2020-06-02 15:50 被阅读0次

    遇到问题有两种解决方案
    flutter有问必答群号: 1051522925

    第一种:

    Mac
    
    //命令行输入
    vim ~/.bash_profile
    
    //添加下面三行,保存
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    export PATH=/Users/计算机名称/flutter/bin:$PATH  //下载的flutterSDK的路径
    
    //命令行输入
    source ~/.bash_profile
    
    flutter -h
    
    Windows 新增两个环境变量
    
    PUB_HOSTED_URL ===== https://pub.flutter-io.cn
    FLUTTER_STORAGE_BASE_URL ===== https://storage.flutter-io.cn
    
    执行一下 flutter doctor命令
    
    提示 zsh: command not found: flutter
    
    MacOS Catalina 10.15.4 ,flutter的命令失效
    
    据官方说,从 macOS Catalina 版开始,您的 Mac 将使用 zsh 作为默认登录 Shell 和交互式 Shell。您还可以在较低版本的 macOS 中将 zsh 设置为默认 Shell。
    
    ##* 单次解决办法
    这种方法,只对当前终端窗口有效,关闭之后无效了
    
    source ~/.bash_profile
    
    ##* 永久解决方法
    1 、执行:【open ~/.zshrc 】
    open ~/.zshrc 
    2 、如果 提示文件不存在,则执行:【vim ~/.zshrc 】新建一个新文件。
    vim ~/.zshrc 
    3 、再执行【open ~/.bash_profile 】
    open ~/.bash_profile
    4 、把 bash_profile 中的内容copy到 zshrc 文件中,保存:【:wq回车】。
    5 、再使用source命令重新加载一下:【source ~/.zshrc】,下次再编辑这个文件就可以直接执行:【open ~/.zshrc】
    source ~/.zshrc
    6 、运行【flutter -h 】看生效没有
    flutter -h
    

    如果你卡着都没问题还是解决不了

    页在“pubspec.yaml”文件下编写:
    
    dependencies:
      flutter_test:
        sdk: flutter
    
     cupertino_icons: ^0.1.3
      dio: ^3.0.9
    
    WechatIMG69.jpeg
    然后点击“flutter packages get”时,可能会在terminal中运行长时间不出结果(Running "flutter packages get" in flutter _demo...)
    
    然后在终端执行解释了,并遇到问题:
    
    问题1:
    
    chenyingyoudeMacBook-Pro:~ yingyou$ flutter packages get
    
    Waiting for another flutter command to release the startup lock…
    
    解决方法,如下: 
    1、关掉Android Studio打开flutter的安装目录/bin/cache/ 
    2、删除lockfile文件 
    3、继续执行终端
    
    问题2:
    
    Error: No pubspec.yaml file found.
    
    This command should be run from the root of your Flutter project.Do not run this command from the root of your git clone of Flutter.
    
    Running "flutter packages get" in flutter_demo…
    
    WeChat35b6942c5c7def145cef7eaf31c207e8.png
    终端cd到flutter工程下执行“flutter packages get”即可!
    
    

    相关文章

      网友评论

          本文标题:Flutter卡在Running "flutter packag

          本文链接:https://www.haomeiwen.com/subject/eewuzhtx.html