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

你可能感兴趣的:(Flutter,macos,flutter,git)