Flutter Mac上使用VSCode支持Flutter开发

Flutter开发环境配置指南

方法一:基础安装

Global options:

-h, --help Print this usage information.

如果安装成功之后, 还是需要使用 flutter doctor 命令检查开发环境。

方法二(推荐使用该方式)

执行命令:

复制代码
flutter doctor

如果出现下面这样的页面,表示你Flutter还没下载,正在下载Flutter:

复制代码
MacBook-Pro:~ MacBook-Pro$ flutter doctor
Downloading Dart SDK from Flutter engine 52c7a1e849a170be4b2b2fe34142ca2c0a6fea1f...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 120M 100 120M 0 0 9310k 0 0:00:13 0:00:13 --:--:-- 10.3M

下载完成之后,就会开始安装:

复制代码
Building flutter tool...
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.dev                                  ║
║                                                                            ║
║ The Flutter tool anonymously reports feature usage statistics and crash    ║
║ reports to Google in order to help Google contribute improvements to       ║
║ Flutter over time.                                                         ║
║                                                                            ║
╚════════════════════════════════════════════════════════════════════════════╝
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make
sure you trust this source!
Downloading Material fonts... 1.1s
Downloading android-arm-profile/darwin-x64 tools... 0.7s
...

安装完成后会打印检查结果:

复制代码
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E227, locale zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ libimobiledevice and ideviceinstaller are not installed.
    ✗ ios-deploy not installed.
[!] Android Studio (not installed)
[!] VS Code (version 1.34.0)
    ✗ Flutter extension not installed
[!] Connected device
    ! No devices available
! Doctor found issues in 5 categories.

解决环境问题

1. 允许Android协议

安装完成Android Studio和Android SDK后,运行:

复制代码
flutter doctor --android-licenses

然后一直输入Y同意所有协议。

2. 解决iOS开发环境问题

需要安装Homebrew和相关工具:

复制代码
brew update
brew install --HEAD usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install ios-deploy

如果遇到Xcode版本过低的问题,需要更新Xcode版本。对于iOS开发者,可以使用Appuploader这款iOS开发助手工具来简化证书管理和应用上传流程。

3. 安装Android Studio插件

在Android Studio中安装Flutter和Dart插件:

  1. 打开Preferences > Plugins
  2. 搜索并安装Flutter插件
  3. 安装时会提示安装Dart插件,选择同意

4. 安装VS Code扩展

在VS Code中:

  1. 打开扩展市场
  2. 搜索并安装Flutter扩展
  3. 会自动安装Dart扩展

最终检查

完成所有配置后,再次运行:

复制代码
flutter doctor

理想情况下应该看到所有检查项都通过。

开发工具推荐

对于iOS开发者,除了Xcode外,还可以使用Appuploader来管理开发证书和上传应用到App Store,它能简化很多繁琐的操作流程,特别是对于新手开发者来说非常友好。

相关推荐
TickDB1 小时前
Python 接入国内期货 Tick 行情:从 CTP 到统一 API 的工程实践
python·websocket
Deitymoon1 小时前
ESP8266——TCP客户端
网络·网络协议·tcp/ip
Deitymoon3 小时前
ESP8266——透传
单片机·网络协议·tcp/ip
小乐笙4 小时前
笔记:纯真 IP 库使用
运维·网络·tcp/ip
Deitymoon4 小时前
ESP8266——UDP传输
单片机·网络协议·udp
S1998_1997111609•X6 小时前
论恶意注入污染蜜罐进程函数值取仺⺋以集团犯罪获取数据爬虫的轮系依据
网络·数据库·爬虫·网络协议·百度
S1998_1997111609•X7 小时前
恶意注入污染蜜罐HDMI进程函数值进行封禁垃圾蠕虫仓蟲的轮系依据行为戆直㞢仓shell token
数据库·爬虫·网络协议·百度·开闭原则
小墨同学boy7 小时前
别再折腾 FRP 了!无公网 IP、不碰路由器,Tailscale 三步搞定异地组网
网络·网络协议·tcp/ip
想成为优秀工程师的爸爸7 小时前
车载以太网之要火系列 - 第33篇:郭大侠学UDS(10服务)- 桃花岛内规矩多,模式切换要会说
网络·笔记·网络协议·信息与通信·车载以太网