美文网首页flutter
Flutter Mac环境配置

Flutter Mac环境配置

作者: zombie | 来源:发表于2020-08-19 22:13 被阅读0次

    1.下载SDK

     export PUB_HOSTED_URL=https://pub.flutter-io.cn
     export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
     git clone https://github.com/flutter/flutter.git -b stable
    

    2.配置环境变量

    • 编辑.bash_profile文件
      ps:如果没有创建过bash_profile用以下命令行创建
    touch .bash_profile // 创建bash_profile
    open .bash_profile // 打开bash_profile 
    source .bash_profile  // 更新bash_profile
    

    打开bash_profile文件 添加如下环境变量

     export PUB_HOSTED_URL=https://pub.flutter-io.cn
     export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
     export Flutter_Home=/Users/xxxx/flutter   // 这个路径为Flutter安装目录
     export PATH=$PATH:$Flutter_Home/bin
     export PATH=$PATH:$Flutter_Home/bin/cache/dart-sdk/bin
    

    添加完成之后 执行source .bash_profile更新环境变量,可以执行echo $PATH查看环境变量是否生效

    • 编辑.zshrc文件 (如果不配置.zshrc 退出当前终端 下次flutter命令还是无效)
      在zshrc文件中添加和bash_profile中同样的环境变量
      ps:如果没有创建过zshrc用以下命令行创建
    touch .zshrc   // 创建zshrc 
    open .zshrc   // 打开zshrc
    source .zshrc  //更新zshrc
    

    3.查看版本,会自动下载sdk

    flutter --version
    

    4.开发二进制文件预下载(可选操作)

    flutter precache 
    

    下载不同平台的开发二进制文件,如果需要一个封闭式的构建环境,或在网络可用性不稳定的情况下使用等情况,可能需要通过这个命令预先下载 iOS 和 Android 的开发二进制文件

    5.平台的配置

    下载Android Studio或者VSCode 在对应IDE中下载Flutter和Dart插件,可以执行flutter doctor验证是否安装成功,以下为配置成功截图

    相关文章

      网友评论

        本文标题:Flutter Mac环境配置

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