【Flutter】在 Windows 上安裝Flutter

獲取 Flutter SDK

  • 使用 git 去克隆倉庫
  • 添加 flutter 工具到環(huán)境變量
  • 運(yùn)行 flutter doctor 來顯示剩下你需要安裝的的依賴。

克隆倉庫

如果這是你第一次在電腦上安裝 Flutter ,需要克隆這個(gè)遠(yuǎn)程倉庫:

$ 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.

要更新現(xiàn)有版本的 Flutter ,參閱 升級(jí) Flutter

更新你的環(huán)境變量

  • 打開 “控制面板 > 系統(tǒng)和安全 > 系統(tǒng) > 高級(jí)系統(tǒng)設(shè)置 > 環(huán)境變量”。
  • 在 Path 變量末尾添加;并且加上 flutter\bin 的全路徑。

運(yùn)行 flutter doctor

打開一個(gè)新的命令提示符運(yùn)行以下的命令,看是否需要安裝依賴項(xiàng)來完成安裝:

$ flutter doctor

你可能會(huì)遇到下載不下來的情況,只需添加如下兩對(duì)鍵值到環(huán)境變量中再次運(yùn)行即可:


image.png
FLUTTER_STORAGE_BASE_URL
https://storage.flutter-io.cn
image.png
PUB_HOSTED_URL
https://pub.flutter-io.cn

PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL是谷歌的國內(nèi)臨時(shí)鏡像。

接下來運(yùn)行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!

環(huán)境OK,輸入flutter devices查看電腦已連接的設(shè)備:

D:\>flutter devices
1 connected device:

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

創(chuàng)建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\Icon-App-1024x1024@1x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (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\LaunchImage@2x.png (created)
  myapp\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (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.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。http://www.itdecent.cn/p/399c0...
    AWeiLoveAndroid閱讀 67,997評(píng)論 43 189
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,554評(píng)論 19 139
  • 不定詞短語可以當(dāng)名詞、形容詞、副詞來使用,往往帶有不確定的意思,所以叫做“不定”。 規(guī)則:不定詞是助詞的變化,帶有...
    唐魚的學(xué)習(xí)探索閱讀 1,900評(píng)論 0 2
  • 閉包是指有權(quán)訪問另一個(gè)函數(shù)作用域中的變量的函數(shù)。創(chuàng)建閉包的常見方式,就是在一個(gè)函數(shù)內(nèi)部創(chuàng)建另一個(gè)函數(shù)。 1. 閉包...
    klmhly閱讀 216評(píng)論 0 0
  • 土豆,學(xué)名馬鈴薯,不是中國本土之物,約17世紀(jì)左右傳入中國,故有別名洋芋之稱,我們小時(shí)候稱之為洋芋或土豆,從...
    NancyQi閱讀 778評(píng)論 4 15

友情鏈接更多精彩內(nèi)容