Flutter環境搭建、運行gallary項目

Flutter環境搭建、運行gallary項目

主體步驟

一、從github clone flutter的sdk,android

git clone -b beta https://github.com/flutter/flutter.git
複製代碼

具體步驟參照官方文檔。flutter.io/get-started…ios

二、配置環境變量 zsh用戶配置~/.zshrc文件,添加進環境變量。以下所示。 前兩個是國內用戶配置的鏡像地址,第三個第四個是剛纔clone下來的項目的文件目錄,具體到bin目錄下。git

//flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PWD=/Users/XXX/flutter/bin
export PATH="${PWD}:${PATH}"
複製代碼

配置完成以後,刷新終端。github

使用echo $PATH命令查看環境變量是否配置成功。xcode

三、使用flutter doctor命令來執行Flutter的安裝程序了。這裏貼上我執行完doctor命令以後的診斷信息,以下所示:bash

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.13.6 17G2208, locale en-CN)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.2)
! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop for iOS devices
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side. Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS. For more info, see https://flutter.io/platform-plugins To install: brew install cocoapods pod setup [✓] Android Studio (version 3.1) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] VS Code (version 1.28.2) [!] Connected devices ! No devices available ! Doctor found issues in 4 categories. 複製代碼

總結一下,關鍵信息以下:app

  • Flutter的版本號及相關信息。
  • Android工具鏈信息,Android SDK 版本等。
  • IOS工具鏈信息,xcode等相關工具須要安裝。
  • Android Studio相關信息,須要安裝Flutter和Dart插件。
  • VS Code相關信息。
  • 已鏈接的設備信息:無。

這裏給出的提示很詳細,均提供了對應的解決方式,根據提示去逐步安裝便可。ide

四、Android Studio插件安裝失敗。 須要更新Android Studio到最新版,而後再手動安裝Dart和flutter插件。工具

  • 去官網下載最新版的Andorid Studio,這裏是3.2.1,下載完成以後覆蓋安裝。
  • 下載與Android Studio兼容的Dart插件。

五、運行代碼:下載一個IntelliJ,而後打開項目 項目根目錄爲 ../flutter/examples/flutter_gallary 錯誤解決:pubspec.yaml中,版本號不匹配ui

Running "flutter packages get" in flutter_gallery...            
Because flutter_gallery depends on flutter_driver any from sdk which depends on source_maps 0.10.7, source_maps 0.10.7 is required.
So, because flutter_gallery depends on source_maps 0.10.8, version solving failed.

pub get failed (1)
Process finished with exit code 1
複製代碼

解決方式:切換到beta分支便可。

git checkout -b beta origin/beta
複製代碼

參考

官方文檔 github地址 插件開發,引用插件報plugin 「XXX」is incompatible with this installation 玉剛說

相關文章
相關標籤/搜索