一、安裝資料
可以去官網下載flutter,也可以通過git,下面倆個地址都可以
git clone -b alpha https://github.com/flutter/flutter.git
git clone https://github.com/flutter/flutter.git
下載完
二、配置環境變量
1.下載好fullter後,配置環境變量.bash_profile
vim ~/.bash_profile
2.添加剛下載的flutter文件bin目錄
export PATH=/Users/Desktop/project/app/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
三、檢查是否安裝成功
1.在命令行輸入flutter或flutter -h
2.輸入flutter doctor,檢查是否安裝完畢
按剛檢查結果查看,上圖存在[!][x]的標示,表示檢測不通過,需要過一些設置或安裝相應的軟件。
然後在命令行輸入
flutter doctor --android-licenses
安裝過程中會提示y/n,一直選擇y
完成後,安裝xcode
然後在進行brew安裝方法:命令行輸入
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安裝完畢。運行命令:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install ios-deploy
brew install cocoapods
pod setup
如果出現錯誤
可以運行
brew link --overwrite cocoapods
然後繼續運行:
pod setup
如果覺得慢,也可以運行
cd ~/.cocoapods/repos
git clone https://github.com/CocoaPods/Specs.git
下載完成後,打開Android studio >preference>plugins ,安裝flutter。
安裝後重啓Android studio,然後運行
flutter doctor
flutter doctor
這裏有個坑,如果按照指引來做,會一直卡在這裏。需要重新安裝python
brew reinstall python@2
pip install six
再次運行
flutter doctor
到此,我們環境配置完成。