【Flutter】在 Windows 上安装Flutter

获取 Flutter SDK

  • 使用 git 去克隆仓库
  • 添加 flutter 工具到环境变量
  • 运行 flutter doctor 来显示剩下你需要安装的的依赖。

克隆仓库

如果这是你第一次在电脑上安装 Flutter ,需要克隆这个远程仓库:

$ git clone -b beta https://github.com/flutter/flutter.git
D:\>git clone -b beta https://github.com/flutter/flutter.git
Cloning into 'flutter'...
remote: Counting objects: 128732, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 128732 (delta 0), reused 0 (delta 0), pack-reused 128729
Receiving objects: 100% (128732/128732), 40.15 MiB | 500.00 KiB/s, done.
Resolving deltas: 100% (96845/96845), done.
Checking out files: 100% (2543/2543), done.

要更新现有版本的 Flutter ,参阅 升级 Flutter

更新你的环境变量

  • 打开 “控制面板 > 系统和安全 > 系统 > 高级系统设置 > 环境变量”。
  • 在 Path 变量末尾添加;并且加上 flutter\bin 的全路径。

运行 flutter doctor

打开一个新的命令提示符运行以下的命令,看是否需要安装依赖项来完成安装:

$ flutter doctor

你可能会遇到下载不下来的情况,只需添加如下两对键值到环境变量中再次运行即可:


【Flutter】在 Windows 上安装Flutter_第1张图片
image.png
FLUTTER_STORAGE_BASE_URL
https://storage.flutter-io.cn
【Flutter】在 Windows 上安装Flutter_第2张图片
image.png
PUB_HOSTED_URL
https://pub.flutter-io.cn

PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL是谷歌的国内临时镜像。

接下来运行flutter doctor

D:\>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[√] Connected devices (1 available)

• No issues found!

环境OK,输入flutter devices查看电脑已连接的设备:

D:\>flutter devices
1 connected device:

ONEPLUS A3010 • c402b0b1 • android-arm64 • Android 7.1.1 (API 25)

创建APP:

flutter create myapp
E:\Work>flutter create myapp
Creating project myapp...
  myapp\.gitignore (created)
  myapp\.idea\libraries\Dart_SDK.xml (created)
  myapp\.idea\libraries\Flutter_for_Android.xml (created)
  myapp\.idea\modules.xml (created)
  myapp\.idea\runConfigurations\main_dart.xml (created)
  myapp\.idea\workspace.xml (created)
  myapp\.metadata (created)
  myapp\android\app\build.gradle (created)
  myapp\android\app\src\main\java\com\example\myapp\MainActivity.java (created)
  myapp\android\build.gradle (created)
  myapp\android\.gitignore (created)
  myapp\android\app\src\main\AndroidManifest.xml (created)
  myapp\android\app\src\main\res\drawable\launch_background.xml (created)
  myapp\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  myapp\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  myapp\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  myapp\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  myapp\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  myapp\android\app\src\main\res\values\styles.xml (created)
  myapp\android\gradle\wrapper\gradle-wrapper.properties (created)
  myapp\android\gradle.properties (created)
  myapp\android\settings.gradle (created)
  myapp\ios\Runner\AppDelegate.h (created)
  myapp\ios\Runner\AppDelegate.m (created)
  myapp\ios\Runner\main.m (created)
  myapp\ios\Runner.xcodeproj\project.pbxproj (created)
  myapp\ios\.gitignore (created)
  myapp\ios\Flutter\AppFrameworkInfo.plist (created)
  myapp\ios\Flutter\Debug.xcconfig (created)
  myapp\ios\Flutter\Release.xcconfig (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\[email protected] (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  myapp\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  myapp\ios\Runner\Base.lproj\Main.storyboard (created)
  myapp\ios\Runner\Info.plist (created)
  myapp\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  myapp\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  myapp\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  myapp\lib\main.dart (created)
  myapp\myapp.iml (created)
  myapp\myapp_android.iml (created)
  myapp\pubspec.yaml (created)
  myapp\README.md (created)
  myapp\test\widget_test.dart (created)
Wrote 65 files.

Running "flutter packages get" in myapp...

[√] Flutter is fully installed. (Channel beta, v0.5.1, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices is fully installed. (Android SDK 27.0.3)
[√] Android Studio is fully installed. (version 3.1)
[√] Connected devices is fully installed. (1 available)

All done! In order to run your application, type:

  $ cd myapp
  $ flutter run

Your main program file is lib/main.dart in the myapp directory.

你可能感兴趣的:(【Flutter】在 Windows 上安装Flutter)