如何在 MacOS 上安装 Flutter ?

Flutter 是 Google 开发的一个功能强大的框架,它允许开发人员从单个代码库构建高质量的、本机编译的移动、web 和桌面应用程序。如果你是初次接触 Flutter,并希望在你的 macOS 系统上安装它,本指南将引导你一步一步地完成这个过程。

Step 1: Installing Homebrew

打开终端,粘贴如下命令并执行

复制代码
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

按照屏幕上的说明完成安装。你可能会被要求输入你的密码。

安装完成后,查看 brew 版本

复制代码
brew --version

Step 2: Installing Flutter

在终端中执行如下命令

复制代码
brew install --cask flutter

此命令将在 Mac 上下载并安装 Flutter,此过程可能需要一些时间。

安装完成后,查看 flutter 版本

复制代码
flutter --version

Step 3: Running Flutter Doctor

安装 Flutter 之后,运行 flutter doctor 命令非常重要,它将检查您的环境并报告任何缺失的依赖项。

复制代码
flutter doctor

Step 4: Installing Additional Tools

根据 flutter doctor 提供的说明,您可能需要安装其他工具。下面是我运行的命令,以确保一切设置正确。

Install Rosetta (required for Apple Silicon Macs)

复制代码
sudo softwareupdate --install-rosetta --agree-to-license

Install Android Studio (necessary for Android development)

复制代码
brew install --cask android-studio

Set Xcode's command-line tools location

复制代码
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Complete initial Xcode setup

复制代码
sudo xcodebuild -runFirstLaunch

Install CocoaPods (used for managing iOS dependencies)

复制代码
brew install cocoapods

Download iOS platform tools

复制代码
xcodebuild -downloadPlatform iOS

Step 5: Setting Up the Android Environment

要搭建 Android 环境,需要配置 Android SDK 并接受 license

Install the latest command-line tools for Android

复制代码
sdkmanager --install "cmdline-tools;latest"

Accept Android licenses

复制代码
flutter doctor --android-licenses

Set the Android SDK location (if not automatically detected)

复制代码
flutter config --android-sdk /path/to/your/android-sdk

Step 6: Running Flutter Doctor Again

现在所有工具和依赖项都已安装,再次运行 flutter doctor 以确保一切都正确设置。

复制代码
flutter doctor

如果一切都配置正确,您应该在每个项目旁边看到复选标记,表明环境已准备好,可以进行 Flutter 开发。

我的开源项目

相关推荐
Mintimate18 小时前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
恋猫de小郭2 天前
Amper 正式转正 Kotlin Toolchain ,Gradle 未来何去何从
android·前端·flutter
fthux2 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
张风捷特烈2 天前
Flutter 类库大揭秘#02 | path_provider 各平台实现
前端·flutter
TT_Close3 天前
别劝退了!5秒搞定 Flutter 鸿蒙 FVM 起跑线
flutter·harmonyos·visual studio code
你听得到113 天前
用户说 App 卡,但说不清在哪?我把 Flutter 监控 SDK 升级成了链路观测工作台
前端·flutter·性能优化
stringwu5 天前
Flutter 开发必备:MVI 架构的高效实现指南
前端·flutter
counterxing5 天前
最近发现一个 Mac 工具,有点像把 Raycast、语音输入法、截图和录屏塞到了一起
macos·ai编程·claude
程序员老刘5 天前
Flutter版本选择指南:3.44系列继续观望 | 2026年6月
flutter·ai编程·客户端
用户965597361907 天前
Provider vs Bloc vs GetX vs Riverpod:Flutter 状态管理方案怎么选?
flutter