获取 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 变量末尾添加;并且加上 flutterbin 的全路径。

运行 flutter doctor

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

$ flutter doctor

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

frc 9c5cb2b1867a465866d876fc2ea16606 - 【Flutter】在 Windows 上安装Flutter
image.png
FLUTTER_STORAGE_BASE_URL
https://storage.flutter-io.cn
frc cf9c43e6be4fc7c51c486261cda1cf73 - 【Flutter】在 Windows 上安装Flutter
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.idealibrariesDart_SDK.xml (created)
  myapp.idealibrariesFlutter_for_Android.xml (created)
  myapp.ideamodules.xml (created)
  myapp.idearunConfigurationsmain_dart.xml (created)
  myapp.ideaworkspace.xml (created)
  myapp.metadata (created)
  myappandroidappbuild.gradle (created)
  myappandroidappsrcmainjavacomexamplemyappMainActivity.java (created)
  myappandroidbuild.gradle (created)
  myappandroid.gitignore (created)
  myappandroidappsrcmainAndroidManifest.xml (created)
  myappandroidappsrcmainresdrawablelaunch_background.xml (created)
  myappandroidappsrcmainresmipmap-hdpiic_launcher.png (created)
  myappandroidappsrcmainresmipmap-mdpiic_launcher.png (created)
  myappandroidappsrcmainresmipmap-xhdpiic_launcher.png (created)
  myappandroidappsrcmainresmipmap-xxhdpiic_launcher.png (created)
  myappandroidappsrcmainresmipmap-xxxhdpiic_launcher.png (created)
  myappandroidappsrcmainresvaluesstyles.xml (created)
  myappandroidgradlewrappergradle-wrapper.properties (created)
  myappandroidgradle.properties (created)
  myappandroidsettings.gradle (created)
  myappiosRunnerAppDelegate.h (created)
  myappiosRunnerAppDelegate.m (created)
  myappiosRunnermain.m (created)
  myappiosRunner.xcodeprojproject.pbxproj (created)
  myappios.gitignore (created)
  myappiosFlutterAppFrameworkInfo.plist (created)
  myappiosFlutterDebug.xcconfig (created)
  myappiosFlutterRelease.xcconfig (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetContents.json (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-1024x1024@1x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@1x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@2x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@3x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@1x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@2x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@3x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@1x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@2x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@3x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-60x60@2x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-60x60@3x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-76x76@1x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-76x76@2x.png (created)
  myappiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-83.5x83.5@2x.png (created)
  myappiosRunnerAssets.xcassetsLaunchImage.imagesetContents.json (created)
  myappiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage.png (created)
  myappiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage@2x.png (created)
  myappiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage@3x.png (created)
  myappiosRunnerAssets.xcassetsLaunchImage.imagesetREADME.md (created)
  myappiosRunnerBase.lprojLaunchScreen.storyboard (created)
  myappiosRunnerBase.lprojMain.storyboard (created)
  myappiosRunnerInfo.plist (created)
  myappiosRunner.xcodeprojproject.xcworkspacecontents.xcworkspacedata (created)
  myappiosRunner.xcodeprojxcshareddataxcschemesRunner.xcscheme (created)
  myappiosRunner.xcworkspacecontents.xcworkspacedata (created)
  myapplibmain.dart (created)
  myappmyapp.iml (created)
  myappmyapp_android.iml (created)
  myapppubspec.yaml (created)
  myappREADME.md (created)
  myapptestwidget_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