MAC上Flutter環境搭建記錄

MQ晝夜發表於2021-07-29

官網

配置國內映象

下載安裝Flutter

  • 下載Flutter SDK,解壓配置即可;

  • 通過 git 方式獲取(推薦此方式):

    git clone github.com/flutter/flu… -b stable

  • 遇到問題:SSL_ERROR_SYSCALL in connection to github.com:443

    fatal: unable to access 'github.com/flutter/flu…': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

  • 解決方案:分為http和https

    git config --global --unset http.proxygit config --global --unset https.proxy

設定完以後重啟終端!

 將 Flutter 新增全域性環境變數

  • 開啟(或建立) .bash_profile. 我在 本使用者名稱 資料夾下建立

參考flutter中文網教程:開啟(或建立) $HOME/.bash_profile. 檔案路徑和檔名可能在您的機器上不同.

open .bash_profile 檢視是否有.bash_profile  檔案,如無 touch .bash_profile

新增如下配置

export PUB_HOSTED_URL=https://pub.flutter-io.cn //國內使用者需要設定
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //國內使用者需要設定
export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
複製程式碼
  • 注意:PATH_TO_FLUTTER_GIT_DIRECTORY 為你flutter的路徑,比如“~/document/code”

    #我的配置如下 export PATH=/Users/使用者名稱資料夾/flutter/bin:$PATH

  • 隨後,通過 which flutter 驗證已配置的 Flutter 是否可用:

    which flutter

 通過 flutter doctor 驗證當前 Flutter 開發環境是否完善

flutter doctor
複製程式碼
  • 遇到問題:Failed to retrieve the Dart SDK

    Downloading Dart SDK from Flutter engine 241c87ad800beeab545ab867354d4683d5bfb6ce... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:03:02 --:--:-- 0 curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to storage.googleapis.com:443

    Failed to retrieve the Dart SDK from: storage.googleapis.com/flutter_inf… If you're located in China, please see this page: flutter.dev/community/c…

解決辦法:切換了下VPN的伺服器節點,就好了。猜測是網路不好!

重新執行之後正常:如圖

環境搭建完成,還差 Android Studio 需要安裝和配置。

相關文章