下載最新的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
修改以后的文件如下圖所示:
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.