一、Window10 x64 中flutter环境搭建
0.安装git,并配置git的环境变量:
即将 git安装目录\bin 配置到系统变量path中
如我的是 D:\Program Files\Git\bin\
1.获取flutter sdk(需FQ)
a)Flutter github网站上下载sdk的zip安装包:https://github.com/flutter/flutter/releases
b)解压,并配置flutter sdk的环境变量
比如我解压后的目录为 F:\flutter\flutter-1.20.3\
将 F:\flutter\flutter-1.20.3\bin\ 配置到系统变量path中
创建系统变量PUB_HOSTED_URL、FLUTTER_STORAGE_BASE_URL
PUB_HOSTED_URL 值为 https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL 值为 https://storage.flutter-io.cn
c)打开cmd命令行窗口,进入到flutter sdk目录
C:\Users\alex>cd f:\flutter\flutter-1.20.3
C:\Users\alex>f:
使用如下命令初始化git相关,否则下载完整sdk依赖时会报错,或无法成功创建flutter项目
git init
git commit --allow-empty -n -m "Initial commit"
使用如下命令下载完整flutter sdk所有依赖
flutter doctor
2.Android studio中安装flutter插件(flutter插件中自带dart插件),安装后可以在Android studio中创建flutter项目了(Android studio下载与安装自行百度)
Android studio->File->Settings->Plugins->Marketplace->搜索flutter->安装成功后需要重启IDE
3.Android studio创建flutter项目
Android studio->File->new->new Flutter project...->Flutter Application->Next->录入项目信息->finish
Project name(项目名-替换成自己的): flutter_app
Flutter SDK path(Flutter SDK路径-替换成自己的): F:\flutter\flutter-1.20.3
Project location(项目存放位置-替换成自己的):F:\flutter_workspace
二、Ubuntu 14.04 x64中flutter环境搭建
0.安装git,并配置git的环境变量:
$ sudo apt-get install git
1.获取flutter sdk(需FQ)
a)Flutter github网站上下载sdk的tar.gz安装包:https://github.com/flutter/flutter/releases
b)放到某目录后解压,并配置flutter sdk的环境变量
比如我解压后的目录为 /android/flutter/flutter-1.20.3
进入目标目录(若不存在可使用 sudo mkdir /android/flutter -p 进行创建)
cd /android/flutter
解压命令:
sudo tar -xzf flutter-1.20.3.tar.gz
修改flutter目录权限,否则可能下载sdk时无法创建目录
sudo chmod 777 /android/flutter -R
使用如下命令将 F:\flutter\flutter-1.20.3\bin\ 配置到系统变量path中
sudo vim /etc/profile
在文件尾加入如下内容
# flutter sdk path
export PATH=/android/flutter/flutter-1.20.3/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
输入 :wq 保存并退出文件编辑
使用如下命令使配置立马生效
. /etc/profile
c)打开terminal命令行窗口,进入到flutter sdk目录
cd /android/flutter/flutter-1.20.3
使用如下命令初始化git相关,否则下载完整sdk依赖时会报错,或无法成功创建flutter项目
git init
git commit --allow-empty -n -m "Initial commit"
使用如下命令下载完整flutter sdk所有依赖
flutter doctor
2.Android studio中安装flutter插件(flutter插件中自带dart插件),安装后可以在Android studio中创建flutter项目了(Android studio下载与安装自行百度)
Android studio->File->Settings->Plugins->Marketplace->搜索flutter->安装成功后需要重启IDE
3.Android studio创建flutter项目
Android studio->File->new->new Flutter project...->Flutter Application->Next->录入项目信息->finish
Project name(项目名-替换成自己的): flutter_app
Flutter SDK path(Flutter SDK路径-替换成自己的): F:\flutter\flutter-1.20.3
Project location(项目存放位置-替换成自己的):F:\flutter_workspace