Flutter 安装实践
2018-10-01 本文已影响50人
浮生随笔
Flutter 安装
我的安装步骤可能和网络上的步骤不太一样,但是,却是最好用的。
本篇只是安装步骤简单索引,后续会详细解释每一步。
clone flutter SDK 到本地
最好是cd到根目录下操作:
git clone -b master https://github.com/flutter/flutter.git ./flutter/bin/flutter --version
导出环境变量
终端运行:vim ~/.bash_profile
或者:
- 显示隐藏文件:
defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder
- 用编辑器打开
.bash_profile
直接进行编辑
#Flutter
export PATH=$PATH:/Users/你的Mac名字/flutter/bin
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
flutter doctor
-
打开终端,准备运行命令
-
cd 到根目录下,终端运行:
export PATH=`pwd`/flutter/bin:$PATH
这行命令的目的是,能在该目录下使用 flutter 作为命令进行操作。
-
检查安装插件情况:
flutter doctor
-
open -a Simulator
brew update
brew install --HEAD libimobiledevice
brew install ideviceinstaller ios-deploy cocoapods
pod setup
-
查看可用设备:
查看可连接设备状态flutter devices
-
在设备上运行APP:
flutter run -d 上面命令获取的设备ID
iterm-2 配色导致每次flutter 命令运行或者 source ~/.bash_profile
都会把用户名变为乱码
-
.zshrc
文件最后面添加一行source .bash_profile
-
把配色的三行export 注释掉
我的.bash_profile
#Android
#export ANDROID_HOME=/Users/zhouzuosong/Library/Android/sdk
#export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tool
#export PATH=/usr/local/mysql/bin:$PATH
export ANDROID_HOME=/Users/zhouzuosong/Library/Android/sdk
export PATH=PATH:$ANDROID_HOME/tools:$PATH
export PATH=PATH:$ANDROID_HOME/platform-tools:$PATH
#Flutter
export PATH=$PATH:/Users/zhouzuosong/flutter/bin
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
# iterm 配色
# #enables colorin the terminal bash shell export
# export CLICOLOR=1
# #setsup thecolor scheme for list export
# export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
# #sets up theprompt color (currently a green similar to linux terminal)
# export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$'
# #enables colorfor iTerm
# export TERM=xterm-256color
拿走不谢~