配置 Flutter 环境

2020-05-16  本文已影响0人  打碟的DJ

Flutter 环境配置

配置环境变量

# 国内用户需要设置
export PUB_HOSTED_URL=https://pub.flutter-io.cn 

# 国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn 

# 设置flutter的路径
export PATH=~/Documents/flutter/bin:$PATH

注意:PATH_TO_FLUTTER_GIT_DIRECTORY 为你flutter的路径,比如“~/Documents/flutter”

export PATH=~~/Documents/flutter/bin:$PATH
echo $PATH
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, set
      ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.

该情况是未安装 Android Studio,请先安装 Android Studio

[!] Android Studio (version 3.6)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.

该情况是因为 android studio 里还少了两个插件。我们打开 andriod studio。

[!] VS Code (version 1.45.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

该情况是在 vscode 中未配置 flutter 插件,搜索 flutter 和 Dart 插件安装

配置编辑器

一般编写 Flutter 可以使用 Android Studio 和 Visual Studio Code,Flutter官网配置编辑器教程

配置 Android Studio

7.5、点击红色框内的按钮运行模拟器


配置 VS Code

1、下载安装 VS Code

下载 VS Code

2、安装 Flutter 插件


安装 Flutter插件

3、通过 Flutter Doctor 验证您的设置


验证设置

运行项目

Flutter 官方运行项目

Android Studio 运行项目

创建项目 iOS运行效果

VS Code 运行项目

以上就是 Flutter 配置环境的整个流程,下面开始我们的 Flutter 编程之旅吧!!!

上一篇下一篇

猜你喜欢

热点阅读