install-flutter-from-git

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Install Flutter from Git

从Git安装Flutter

This skill guides you through installing the Flutter SDK using
git clone
and setting up the environment for Web, Mobile, and Desktop development.
本指南将引导你使用
git clone
安装Flutter SDK,并为Web、移动和桌面开发配置环境。

1. 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
undefined

Create a directory for development (e.g., ~/development)

创建开发目录(例如:~/development)

mkdir -p ~/development cd ~/development
mkdir -p ~/development cd ~/development

Clone the Flutter SDK

克隆Flutter SDK

undefined
undefined

Windows

Windows

Open PowerShell or Command Prompt.
powershell
undefined
打开PowerShell或命令提示符。
powershell
undefined

Create 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

undefined
undefined

3. Add Flutter to PATH

3. 将Flutter添加至PATH

To run
flutter
commands from any terminal, you must add the SDK's
bin
directory to your PATH.
要在任意终端中运行
flutter
命令,你需要将SDK的
bin
目录添加至系统PATH。

macOS (Zsh) / Linux (Bash/Zsh)

macOS(Zsh)/ Linux(Bash/Zsh)

  1. Open your shell configuration file (e.g.,
    ~/.zshrc
    ,
    ~/.bashrc
    , or
    ~/.zshenv
    ).
  2. Add the following line (replace
    ~/development/flutter
    with your actual path):
    bash
    export PATH="$PATH:$HOME/development/flutter/bin"
  3. Refresh your current terminal:
    bash
    source ~/.zshrc  # or ~/.bashrc
  1. 打开你的shell配置文件(例如:
    ~/.zshrc
    ~/.bashrc
    ~/.zshenv
    )。
  2. 添加以下行(将
    ~/development/flutter
    替换为你的实际路径):
    bash
    export PATH="$PATH:$HOME/development/flutter/bin"
  3. 刷新当前终端:
    bash
    source ~/.zshrc  # 或 ~/.bashrc

Windows

Windows

  1. Press
    Win + S
    , type "env", and select Edit the system environment variables.
  2. Click Environment Variables.
  3. Under User variables, select Path and click Edit.
  4. Click New and add the full path to
    flutter\bin
    (e.g.,
    C:\src\flutter\bin
    ).
  5. Click OK on all windows.
  6. Restart your terminal/PowerShell.
  1. 按下
    Win + S
    ,输入“环境变量”,选择编辑系统环境变量
  2. 点击环境变量
  3. 用户变量下,选择Path并点击Edit
  4. 点击New,添加
    flutter\bin
    的完整路径(例如:
    C:\src\flutter\bin
    )。
  5. 点击所有窗口的OK
  6. 重启你的终端/PowerShell。

4. Verify Installation

4. 验证安装

Run the following command to check for missing dependencies:
bash
flutter doctor
运行以下命令检查缺失的依赖:
bash
flutter doctor

5. Platform Setup

5. 平台配置

Web (Chrome)

Web(Chrome)

  1. Install Chrome: Ensure Google Chrome is installed.
  2. Enable Web Support (usually enabled by default):
    bash
    flutter config --enable-web
  3. Verify: Run
    flutter devices
    to see "Chrome" listed.
  1. 安装Chrome:确保已安装Google Chrome。
  2. 启用Web支持(通常默认已启用):
    bash
    flutter config --enable-web
  3. 验证:运行
    flutter devices
    查看是否列出“Chrome”。

Mobile (iOS & Android)

移动平台(iOS & Android)

iOS (macOS only)

iOS(仅macOS)

  1. Install Xcode: Download from the Mac App Store.
  2. Configure Command Line Tools:
    bash
    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -runFirstLaunch
  3. Install CocoaPods (for dependency management):
    bash
    sudo gem install cocoapods
  4. Simulator: Open via
    open -a Simulator
    .
  1. 安装Xcode:从Mac App Store下载。
  2. 配置命令行工具
    bash
    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -runFirstLaunch
  3. 安装CocoaPods(用于依赖管理):
    bash
    sudo gem install cocoapods
  4. 模拟器:通过
    open -a Simulator
    打开。

Android (All Operating Systems)

Android(全操作系统)

  1. Install Android Studio: Download here.
  2. Install SDK Components:
    • Open Android Studio -> SDK Manager.
    • Install Android SDK Platform-Tools.
    • Install Android SDK Command-line Tools (latest).
  3. Accept Licenses:
    bash
    flutter doctor --android-licenses
    (Press
    y
    to accept all licences).
  4. Emulator: Create a device in AVD Manager.
  1. 安装Android Studio点击下载
  2. 安装SDK组件
    • 打开Android Studio -> SDK管理器。
    • 安装Android SDK Platform-Tools
    • 安装Android SDK Command-line Tools(最新版)
  3. 接受许可证
    bash
    flutter doctor --android-licenses
    (按
    y
    接受所有许可证).
  4. 模拟器:在AVD管理器中创建设备。

Desktop (macOS, Windows, Linux)

桌面平台(macOS、Windows、Linux)

macOS Desktop

macOS桌面

  1. Install Xcode: (Same as iOS steps above).
  2. Enable macOS:
    bash
    flutter config --enable-macos-desktop
  1. 安装Xcode:(与iOS步骤相同)。
  2. 启用macOS支持
    bash
    flutter config --enable-macos-desktop

Windows Desktop

Windows桌面

  1. Install Visual Studio (not VS Code): Download VS Community.
  2. Workloads: When installing, select Desktop development with C++.
  3. Enable Windows:
    bash
    flutter config --enable-windows-desktop
  1. 安装Visual Studio(非VS Code):下载VS社区版
  2. 工作负载:安装时选择使用C++的桌面开发
  3. 启用Windows支持
    bash
    flutter config --enable-windows-desktop

Linux Desktop

Linux桌面

  1. 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
  2. Enable Linux:
    bash
    flutter config --enable-linux-desktop
  1. 安装依赖(Ubuntu/Debian示例):
    bash
    sudo apt-get update
    sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
  2. 启用Linux支持
    bash
    flutter config --enable-linux-desktop

6. Final Check

6. 最终检查

Run
flutter doctor
again to ensure all desired platforms have checkmarks.
bash
flutter doctor -v
再次运行
flutter doctor
确保所有目标平台都显示对勾。
bash
flutter doctor -v