Flutter环境变量配置

Posted stevenhusir

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter环境变量配置相关的知识,希望对你有一定的参考价值。

Flutter环境变量配置

1.下载Flutter SDK

2.配置环境变量

在当前用户目录下创建.bash_profile文件,如果该文件已经存在,则直接打开.

打开配置文件

open -e .bash_profile

配置

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/hujintao/flutter/bin:$PATH

export android_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

export PATH=$PATH:$ANDROID_HOME/emulator

export RN=/usr/local/bin
export PATH=$RN:$PATH

GRADLE_HOME=/Users/Apple/Desktop/soft/gradle/gradle-4.6 
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin

export NVM_DIR=~/.nvm
source $(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环境变量配置的主要内容,如果未能解决你的问题,请参考以下文章

Mac下如何配置环境变量

Flutter环境变量配置

Flutter环境变量配置

Flutter环境变量配置

vscode flutter 环境搭建

Flutter学习笔记·安装配置Flutter环境(Windows)