一、在macOS上配置Flutter環(huán)境變量

下載最新的Flutter SDK

1薇芝、官網下載地址https://flutter.dev/docs/development/tools/sdk/releases?tab=macos#macos
2沮趣、GitHub下載地址https://github.com/flutter/flutter/releases
??:在macOS上下載最新的flutter sdk以后,會自動解壓到當前下載文件夾舔株,你要做的就是將解壓后的flutter文件放置到你想進行flutter開發(fā)的文件夾下,并通過pwd命令獲取當前文件夾路徑以備用还棱;

添加環(huán)境變量:

1载慈、通過 bogon:fileDir auth$ cd ~進入到用戶文件夾下;
2珍手、使用bogon:~ auth$ vi .bash_profile命令打開bash命令文件办铡,配置flutter環(huán)境變量;
注意:此處若有.bash_profile文件可以使用上述命令直接進行編輯琳要,若沒有料扰,則使用touch .bash_profile命令創(chuàng)建該文件,再使用上述命令進入編輯頁面
3焙蹭、在vi界面點擊i,再復制粘貼如下代碼:

export PUB_HOSTED_URL=https://pub.flutter-io.cn #國內用戶需要設置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn #國內用戶需要設置
export PATH=剛才下載后解壓的flutter文件路徑/flutter/bin:$PATH

修改以后的文件如下圖所示:

image.png

4嫂伞、點擊esc鍵退出vi編輯孔厉,再點擊shift Q組合鍵拯钻,輸入wq保存文件并回到命令行界面;
5撰豺、輸入bogon:~ auth$ source .bash_profile運行.bash_profile添加環(huán)境變量粪般;
6、輸入bogon:~ auth$ flutter -h不出現(xiàn)-bash: flutter: command not found污桦,并能夠查看flutter的幫助命令亩歹,說明環(huán)境變量配置成功;

bogon:~ auth$ flutter -h
Manage your Flutter app development.

Common commands:

  flutter create <output directory>
    Create a new Flutter project in the specified directory.

  flutter run [options]
    Run your Flutter application on an attached device or in an emulator.

Usage: flutter <command> [arguments]

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands executed.
                            If used with --help, shows hidden options.

-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.
    --bug-report            Captures a bug report file to submit to the Flutter team.
                            Contains local paths, device identifiers, and log snippets.

    --packages              Path to your ".packages" file.
                            (required, since the current directory does not contain a ".packages" file)

Available commands:
  analyze                  Analyze the project's Dart code.
  attach                   Attach to a running application.
  bash-completion          Output command line shell completion setup scripts.
  build                    Flutter build commands.
  channel                  List or switch flutter channels.
  clean                    Delete the build/ and .dart_tool/ directories.
  config                   Configure Flutter settings.
  create                   Create a new Flutter project.
  devices                  List all connected devices.
  doctor                   Show information about the installed tooling.
  drive                    Runs Flutter Driver tests for the current project.
  emulators                List, launch and create emulators.
  format                   Format one or more dart files.
  help                     Display help information for flutter.
  install                  Install a Flutter app on an attached device.
  logs                     Show log output for running Flutter apps.
  make-host-app-editable   Moves host apps from generated directories to non-generated directories so that they
                           can be edited by developers.
  packages                 Commands for managing Flutter packages.
  precache                 Populates the Flutter tool's cache of binary artifacts.
  run                      Run your Flutter app on an attached device.
  screenshot               Take a screenshot from a connected device.
  stop                     Stop your Flutter app on an attached device.
  test                     Run Flutter unit tests for the current project.
  trace                    Start and stop tracing for a running Flutter app.
  upgrade                  Upgrade your copy of Flutter.
  version                  List or switch flutter versions.

Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used options.

查看本機的flutter開發(fā)環(huán)境支持凡橱,按需進行開發(fā)環(huán)境搭建

bogon:~ auth$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ? libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        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.dev/platform-plugins
      To install:
        brew install cocoapods
        pod setup
[!] Android Studio
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
[!] IntelliJ IDEA Ultimate Edition (version 2018.2.4)
    ? Flutter plugin not installed; this adds Flutter specific functionality.
    ? Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.34.0)
    ? Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 6 categories.
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末小作,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子稼钩,更是在濱河造成了極大的恐慌顾稀,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,509評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件坝撑,死亡現(xiàn)場離奇詭異静秆,居然都是意外死亡,警方通過查閱死者的電腦和手機巡李,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,806評論 3 394
  • 文/潘曉璐 我一進店門抚笔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人侨拦,你說我怎么就攤上這事殊橙。” “怎么了阳谍?”我有些...
    開封第一講書人閱讀 163,875評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長矫夯。 經常有香客問我,道長训貌,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,441評論 1 293
  • 正文 為了忘掉前任递沪,我火速辦了婚禮豺鼻,結果婚禮上,老公的妹妹穿的比我還像新娘款慨。我一直安慰自己,他們只是感情好檩奠,可當我...
    茶點故事閱讀 67,488評論 6 392
  • 文/花漫 我一把揭開白布附帽。 她就那樣靜靜地躺著,像睡著了一般井誉。 火紅的嫁衣襯著肌膚如雪蕉扮。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,365評論 1 302
  • 那天颗圣,我揣著相機與錄音喳钟,去河邊找鬼在岂。 笑死,一個胖子當著我的面吹牛洁段,可吹牛的內容都是我干的。 我是一名探鬼主播祠丝,決...
    沈念sama閱讀 40,190評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了擅腰?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,062評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎铃慷,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體犁柜,經...
    沈念sama閱讀 45,500評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡堂淡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,706評論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了绢淀。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,834評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡覆履,死狀恐怖,靈堂內的尸體忽然破棺而出内狗,到底是詐尸還是另有隱情,我是刑警寧澤柳沙,帶...
    沈念sama閱讀 35,559評論 5 345
  • 正文 年R本政府宣布拌倍,位于F島的核電站,受9級特大地震影響柱恤,放射性物質發(fā)生泄漏。R本人自食惡果不足惜梗顺,卻給世界環(huán)境...
    茶點故事閱讀 41,167評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望仑鸥。 院中可真熱鬧,春花似錦眼俊、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,779評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽澎灸。三九已至,卻和暖如春性昭,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背巩梢。 一陣腳步聲響...
    開封第一講書人閱讀 32,912評論 1 269
  • 我被黑心中介騙來泰國打工艺玲, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人饭聚。 一個月前我還...
    沈念sama閱讀 47,958評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親箕速。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,779評論 2 354