Flutter教程:Macos安装与配置

安装和配置步骤

  • (1) 下载SDK,我习惯使用git直接下载
git clone https://github.com/flutter/flutter.git -b stable
  • (2) 打开配置文件,看使用的是啥bash,找到对应配置文件即可
$HOME/.bash_profile
$HOME/.bashrc
$HOME/.zshrc #我修改的这个,详情看文末附录
  • (3) 加入到到环境变量中,[PATH_OF_FLUTTER_GIT_DIRECTORY] t要改成sdk的bin路径
export PATH="$PATH:[PATH_OF_FLUTTER_GIT_DIRECTORY]/bin"
  • (4) 使用source时配置立即生效
 source $HOME/.<rc file>
  • (5) 确认一下环境变量是否导入成功且有效
echo $PATH
  • (6) 再确认一下flutter的路径
which flutter

(7)使用doctor来诊断一下环境是否正常

flutter doctor
[!] Xcode - develop for iOS and macOS
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.

使用命令安装一下:sudo gem install cocoapods

附录

.zshrc 
# color term like 'ls'
export CLICOLOR='Yes'
# custom shell prompt
autoload -U colors && colors
PROMPT="%{$fg[green]%}%n@%m%{$reset_color%} %{$fg[blue]%}%1~%{$reset_color%} %# "

# self defined aliases
alias ll='ls -l'
alias la='ls -a'

#flutter configue
export PATH=/Users/uianster/learn/flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
source ~/.bash_profile

参考:
https://flutter.dev/docs/get-started/install/macos

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值