一.命令输入:
open ~/.bash_profile
里面写入
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=~/Documents/Flutter/flutter/bin:$PATH(前往文件夹~/Documents,在该路径下创建Flutter文件夹)
二.命令输入:
open ~/.zshrc
里面写入(全局更新bash_profile)
source ~/.bash_profile
三.cd到Flutter文件夹下
git clone -b beta https://github.com/flutter/flutter.git
四.待完成后命令输入:
flutter doctor
五.创建项目
默认语言swift
flutter create flutterapp
或者使用oc语言
flutter create -i objc flutterappoc
然后找到Runner.xcworkspace双击打开就行了。
/===========================================================/
注意~注意~注意~:
1.clone flutter失败
出现Cloning into 'flutter'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (7/7), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
出现报错(原因缓存区溢出),输入以下命令:
git config --global http.postBuffer 524288000
git config --list
git config --global core.compression -1
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1
然后继续cd到Flutter文件夹下
git clone -b beta https://github.com/flutter/flutter.git
2.如果自己去flutter官网下载安装包可能会出现如下错误:
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly; to set up Flutter, run the following command:
git clone -b beta github.com/flutter/flu…
所以建议使用git clone -b beta github.com/flutter/flu…