install-flutter-from-git
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstall Flutter from Git
从Git安装Flutter
This skill guides you through installing the Flutter SDK using and setting up the environment for Web, Mobile, and Desktop development.
git clone本指南将引导你使用安装Flutter SDK,并为Web、移动和桌面开发配置环境。
git clone1. Prerequisites (All Platforms)
1. 前置条件(全平台)
Ensure you have the following installed:
- Git: Install Git
- Curl/Unzip (macOS/Linux usually have these; Windows usually needs Git Bash or similar)
确保你已安装以下工具:
- Git:安装Git
- Curl/Unzip(macOS/Linux通常已预装;Windows通常需要Git Bash或类似工具)
2. Install Flutter SDK
2. 安装Flutter SDK
macOS / Linux
macOS / Linux
Open your terminal and run the following commands to clone the stable branch of the Flutter SDK.
bash
undefined打开终端,运行以下命令克隆Flutter SDK的稳定分支。
bash
undefinedCreate a directory for development (e.g., ~/development)
创建开发目录(例如:~/development)
mkdir -p ~/development
cd ~/development
mkdir -p ~/development
cd ~/development
Clone the Flutter SDK
克隆Flutter SDK
git clone https://github.com/flutter/flutter.git -b stable
undefinedgit clone https://github.com/flutter/flutter.git -b stable
undefinedWindows
Windows
Open PowerShell or Command Prompt.
powershell
undefined打开PowerShell或命令提示符。
powershell
undefinedCreate a directory for development (e.g., C:\src)
创建开发目录(例如:C:\src)
mkdir C:\src
cd C:\src
mkdir C:\src
cd C:\src
Clone the Flutter SDK
克隆Flutter SDK
git clone https://github.com/flutter/flutter.git -b stable
undefinedgit clone https://github.com/flutter/flutter.git -b stable
undefined3. Add Flutter to PATH
3. 将Flutter添加至PATH
To run commands from any terminal, you must add the SDK's directory to your PATH.
flutterbin要在任意终端中运行命令,你需要将SDK的目录添加至系统PATH。
flutterbinmacOS (Zsh) / Linux (Bash/Zsh)
macOS(Zsh)/ Linux(Bash/Zsh)
-
Open your shell configuration file (e.g.,,
~/.zshrc, or~/.bashrc).~/.zshenv -
Add the following line (replacewith your actual path):
~/development/flutterbashexport PATH="$PATH:$HOME/development/flutter/bin" -
Refresh your current terminal:bash
source ~/.zshrc # or ~/.bashrc
-
打开你的shell配置文件(例如:、
~/.zshrc或~/.bashrc)。~/.zshenv -
添加以下行(将替换为你的实际路径):
~/development/flutterbashexport PATH="$PATH:$HOME/development/flutter/bin" -
刷新当前终端:bash
source ~/.zshrc # 或 ~/.bashrc
Windows
Windows
- Press , type "env", and select Edit the system environment variables.
Win + S - Click Environment Variables.
- Under User variables, select Path and click Edit.
- Click New and add the full path to (e.g.,
flutter\bin).C:\src\flutter\bin - Click OK on all windows.
- Restart your terminal/PowerShell.
- 按下,输入“环境变量”,选择编辑系统环境变量。
Win + S - 点击环境变量。
- 在用户变量下,选择Path并点击Edit。
- 点击New,添加的完整路径(例如:
flutter\bin)。C:\src\flutter\bin - 点击所有窗口的OK。
- 重启你的终端/PowerShell。
4. Verify Installation
4. 验证安装
Run the following command to check for missing dependencies:
bash
flutter doctor运行以下命令检查缺失的依赖:
bash
flutter doctor5. Platform Setup
5. 平台配置
Web (Chrome)
Web(Chrome)
- Install Chrome: Ensure Google Chrome is installed.
- Enable Web Support (usually enabled by default):
bash
flutter config --enable-web - Verify: Run to see "Chrome" listed.
flutter devices
- 安装Chrome:确保已安装Google Chrome。
- 启用Web支持(通常默认已启用):
bash
flutter config --enable-web - 验证:运行查看是否列出“Chrome”。
flutter devices
Mobile (iOS & Android)
移动平台(iOS & Android)
iOS (macOS only)
iOS(仅macOS)
- Install Xcode: Download from the Mac App Store.
- Configure Command Line Tools:
bash
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch - Install CocoaPods (for dependency management):
bash
sudo gem install cocoapods - Simulator: Open via .
open -a Simulator
- 安装Xcode:从Mac App Store下载。
- 配置命令行工具:
bash
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch - 安装CocoaPods(用于依赖管理):
bash
sudo gem install cocoapods - 模拟器:通过打开。
open -a Simulator
Android (All Operating Systems)
Android(全操作系统)
- Install Android Studio: Download here.
- Install SDK Components:
- Open Android Studio -> SDK Manager.
- Install Android SDK Platform-Tools.
- Install Android SDK Command-line Tools (latest).
- Accept Licenses:
(Pressbash
flutter doctor --android-licensesto accept all licences).y - Emulator: Create a device in AVD Manager.
- 安装Android Studio:点击下载。
- 安装SDK组件:
- 打开Android Studio -> SDK管理器。
- 安装Android SDK Platform-Tools。
- 安装Android SDK Command-line Tools(最新版)。
- 接受许可证:
(按bash
flutter doctor --android-licenses接受所有许可证).y - 模拟器:在AVD管理器中创建设备。
Desktop (macOS, Windows, Linux)
桌面平台(macOS、Windows、Linux)
macOS Desktop
macOS桌面
- Install Xcode: (Same as iOS steps above).
- Enable macOS:
bash
flutter config --enable-macos-desktop
- 安装Xcode:(与iOS步骤相同)。
- 启用macOS支持:
bash
flutter config --enable-macos-desktop
Windows Desktop
Windows桌面
- Install Visual Studio (not VS Code): Download VS Community.
- Workloads: When installing, select Desktop development with C++.
- Enable Windows:
bash
flutter config --enable-windows-desktop
- 安装Visual Studio(非VS Code):下载VS社区版。
- 工作负载:安装时选择使用C++的桌面开发。
- 启用Windows支持:
bash
flutter config --enable-windows-desktop
Linux Desktop
Linux桌面
- Install Dependencies (Ubuntu/Debian example):
bash
sudo apt-get update sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - Enable Linux:
bash
flutter config --enable-linux-desktop
- 安装依赖(Ubuntu/Debian示例):
bash
sudo apt-get update sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev - 启用Linux支持:
bash
flutter config --enable-linux-desktop
6. Final Check
6. 最终检查
Run again to ensure all desired platforms have checkmarks.
flutter doctorbash
flutter doctor -v再次运行确保所有目标平台都显示对勾。
flutter doctorbash
flutter doctor -v