如何在 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 开发。

我的开源项目

相关推荐
小锋学长生活大爆炸15 小时前
【开源软件】打造 macOS 纯本地 LLM 工作台 | Sidekick
macos·llm
xmdy586615 小时前
Flutter+开源鸿蒙实战|智联邻里Day1 项目搭建+环境适配+架构规划(十五五民生创新版)
flutter·开源·harmonyos
maaath15 小时前
【maaath】Flutter for OpenHarmony 音乐播放器应用实战开发
flutter·华为·harmonyos
bleuesprit15 小时前
MAC 电脑快速打开claude code 终端
macos
maaath16 小时前
【maaath】 Flutter for OpenHarmony 实战:图片壁纸应用开发指南
flutter·华为·harmonyos
maaath16 小时前
【maaath】Flutter for OpenHarmony:跨平台天气应用开发指南
flutter·华为·harmonyos
maaath16 小时前
【maaath】Flutter for OpenHarmony 宠物社区应用实战开发
flutter·华为·harmonyos
雨声不在16 小时前
mac-intel安装git-lfs
git·elasticsearch·macos
maaath16 小时前
【maaath】Flutter for OpenHarmony 实战:健身运动应用的跨平台开发指南
flutter·华为·harmonyos
maaath16 小时前
【maaath】 Flutter for OpenHarmony 新闻资讯应用实战开发
flutter·华为·harmonyos