下载最新的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开发的文件夹下,并通过pwd
命令获取当前文件夹路径以备用;
添加环境变量:
1、通过 bogon:fileDir auth$ cd ~
进入到用户文件夹下;
2、使用bogon:~ auth$ vi .bash_profile
命令打开bash命令文件,配置flutter环境变量;
注意:此处若有.bash_profile文件可以使用上述命令直接进行编辑,若没有,则使用touch .bash_profile
命令创建该文件,再使用上述命令进入编辑页面
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
添加环境变量;6、输入
bogon:~ auth$ flutter -h
不出现-bash: flutter: command not found
,并能够查看flutter的帮助命令,说明环境变量配置成功;
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开发环境支持,按需进行开发环境搭建
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.
网友评论