篇首语:本文由小编为大家整理,主要介绍了Flutter环境变量配置相关的知识,希望对你有一定的参考价值。
Flutter环境变量配置
1.下载Flutter SDK
一.、使用git克隆Flutter,命令:gitclone -b beta https://github.com/flutter/flutter.git;
二、从官网下载flutter,https://flutter.io/setup-macos/;
2.配置环境变量
在当前用户目录下创建.bash_profile文件,如果该文件已经存在,则直接打开.
打开配置文件
open -e .bash_profile
配置
export PUB_HOSTED_URL=https://pub.flutter-io.cnexport FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cnexport PATH=/Users/hujintao/flutter/bin:$PATHexport android_HOME=$HOME/Library/Android/sdkexport PATH=$PATH:$ANDROID_HOME/toolsexport PATH=$PATH:$ANDROID_HOME/tools/binexport PATH=$PATH:$ANDROID_HOME/platform-toolsexport PATH=$PATH:$ANDROID_HOME/emulatorexport RN=/usr/local/binexport PATH=$RN:$PATHGRADLE_HOME=/Users/Apple/Desktop/soft/gradle/gradle-4.6 export GRADLE_HOMEexport PATH=$PATH:$GRADLE_HOME/binexport NVM_DIR=~/.nvmsource $(brew --prefix nvm)/nvm.sh
其他问题解决
终端执行命令flutter doctor
检测安装依赖
? libimobiledevice and ideviceinstaller are not installed. To install with Brew, run: brew update brew install --HEAD usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install ideviceinstaller ? ios-deploy not installed. To install: brew install ios-deploy[!] Android Studio (version 3.4) ? Flutter plugin not installed; this adds Flutter specific functionality. ? Dart plugin not installed; this adds Dart specific functionality.[!] IntelliJ IDEA Ultimate Edition (version 2018.1.4) ? Flutter plugin not installed; this adds Flutter specific functionality. ? Dart plugin not installed; this adds Dart specific functionality.[!] VS Code (version 1.35.1) ? Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
android studio 配置
解决方案:打开android studio, 打开plugin;
输入flutter搜索,点击中间的 Search in repositories;
需要安装两个插件:
- Flutter插件: 支持Flutter开发工作流 (运行、调试、热重载等).
- Dart插件: 提供代码分析 (输入代码时进行验证、代码补全等).
要安装这些: - 点击install,安装完毕之后重启android studio;
配置模拟器
成功的标志
3.创建新项目
Run the app
//终端下建个文件夹,用命令创建一个flutter项目1. flutter create myapp//进入项目2. cd myapp//run起来3. flutter run
效果图:
Android
iOS
运行在所有可用设备
flutter run -d all
以上是关于Flutter环境变量配置的主要内容,如果未能解决你的问题,请参考以下文章