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

我的开源项目

相关推荐
叽哥9 小时前
Flutter Riverpod上手指南
android·flutter·ios
BG1 天前
Flutter 简仿Excel表格组件介绍
flutter
zhangmeng1 天前
FlutterBoost在iOS26真机运行崩溃问题
flutter·app·swift
恋猫de小郭1 天前
对于普通程序员来说 AI 是什么?AI 究竟用的是什么?
前端·flutter·ai编程
卡尔特斯1 天前
Flutter A GlobalKey was used multipletimes inside one widget'schild list.The ...
flutter
w_y_fan1 天前
Flutter 滚动组件总结
前端·flutter
醉过才知酒浓1 天前
Flutter Getx 的页面传参
flutter
小溪彼岸2 天前
macOS自带截图命令ScreenCapture
macos
火柴就是我2 天前
flutter 之真手势冲突处理
android·flutter
Speed1232 天前
`mockito` 的核心“打桩”规则
flutter·dart