學習如何安裝並手動設定 你的 Flutter 開發環境。

選擇你的開發平台

#

本頁說明內容以在 Windows 裝置上 安裝 Flutter 為主。

如果你想參考其他作業系統的安裝說明, 請選擇下列其中一項。

下載必要軟體

#

在安裝 Flutter SDK(Flutter 軟體開發套件)之前, 請先完成以下設定步驟。

  1. 安裝 Git for Windows

    下載並安裝最新版的 Git for Windows

    若需要安裝或疑難排解 Git, 請參考 Git 文件

  2. 設定編輯器或 IDE

    為獲得最佳的 Flutter 應用程式開發體驗, 建議安裝並設定 支援 Flutter 的編輯器或 IDE

  1. 安裝 Xcode 命令列工具

    下載 Xcode 命令列工具以取得 Flutter 依賴的命令列工具(包含 Git)。

    若要下載這些工具,請在你偏好的終端機中執行下列指令:

    xcode-select --install

    如果你尚未安裝這些工具, 系統會跳出一個對話視窗,確認你是否要安裝它們。 請點選 Install(安裝),安裝完成後再點選 Done(完成)。

  2. 設定編輯器或 IDE

    為了獲得最佳的 Flutter 應用程式開發體驗, 建議你安裝並設定一個 支援 Flutter 的編輯器或 IDE

  1. 下載並安裝必要的套件

    請使用你偏好的套件管理工具或安裝方式, 安裝下列套件的最新版本:

    • curl
    • git
    • unzip
    • xz-utils
    • zip
    • libglu1-mesa

    在以 apt-get 為基礎的 Debian 發行版(如 Ubuntu)上, 請使用以下指令安裝這些套件:

    sudo apt-get update -y && sudo apt-get upgrade -y
    sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
  2. 設定編輯器或 IDE

    為了獲得最佳的 Flutter 應用程式開發體驗, 建議安裝並設定 支援 Flutter 的編輯器或 IDE

  1. 設定 Linux 支援

    如果你之前尚未在 Chromebook 上設定 Linux 支援, 請參考 開啟 Linux 支援

    如果你已經開啟了 Linux 支援, 請依照 修正 Linux 問題 的指示,確保其為最新狀態。

  2. 下載並安裝必要套件

    使用 apt-get 或你偏好的安裝方式, 安裝下列套件的最新版本:

    • curl
    • git
    • unzip
    • xz-utils
    • zip
    • libglu1-mesa

    如果你想使用 apt-get, 請使用下列指令安裝這些套件:

    sudo apt-get update -y && sudo apt-get upgrade -y
    sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
  3. 設定編輯器或 IDE

    為了獲得最佳的 Flutter 應用程式開發體驗, 建議安裝並設定 支援 Flutter 的編輯器或 IDE

安裝並設定 Flutter

#

要安裝 Flutter SDK(Flutter 軟體開發套件), 請從 SDK 歷史版本存檔下載最新的安裝包, 然後將 SDK 解壓縮到你希望儲存的位置。

  1. 下載 Flutter SDK 安裝包

    下載以下安裝包以取得 最新穩定版的 Flutter SDK。

    (loading...)

  2. 建立儲存 SDK 的資料夾

    建立或尋找一個資料夾來儲存解壓縮後的 SDK。 建議在 %USERPROFILE%\developC:\Users\{username}\develop)建立並使用一個目錄。

  3. 解壓縮 SDK

    將你下載的 SDK 安裝包 解壓縮到你想儲存 Flutter SDK 的目錄中。

    1. 複製以下指令。
    2. <sdk_zip_path> 替換為你下載的安裝包路徑。
    3. <destination_directory_path> 替換為你希望解壓縮後 SDK 所在的資料夾路徑。
    4. 在你偏好的終端機中執行已編輯的指令。
    Expand-Archive –Path <sdk_zip_path> -Destination <destination_directory_path>

    例如,如果你已將 Flutter 3.29.3 的 bundle 檔案下載到%USERPROFILE%\Downloads目錄,並希望將解壓後的 SDK 儲存到%USERPROFILE%\develop目錄:

    Expand-Archive `
      -Path $env:USERPROFILE\Downloads\flutter_windows_3.29.3-stable.zip `
      -Destination $env:USERPROFILE\develop\
  1. 下載 Flutter SDK 套件

    根據您的 macOS 裝置 CPU 架構,請下載下列其中一個安裝套件,以取得最新版穩定版的 Flutter SDK。

    Apple Silicon (ARM64)Intel (x64)
    (loading...)(loading...)
  2. 建立儲存 SDK 的資料夾

    請建立或尋找一個資料夾,用來存放解壓縮後的 SDK。建議您在 ~/develop/ 建立並使用一個目錄。

  3. 解壓縮 SDK

    將您下載的 SDK 套件解壓縮到您希望存放 Flutter SDK 的目錄中。

    1. 複製下方指令。
    2. <sdk_zip_path> 替換為您下載的套件檔案路徑。
    3. <destination_directory_path> 替換為您希望解壓縮後 SDK 所在的資料夾路徑。
    4. 在您偏好的終端機中執行編輯後的指令。
    unzip <sdk_zip_path> -d <destination_directory_path>

    例如,假設你已將 Flutter 3.29.3 的 bundle 檔案下載到~/Downloads目錄,並希望將解壓縮後的 SDK 儲存在~/develop目錄:

    unzip ~/Downloads/flutter_macos_3.29.3-stable.zip -d ~/develop/
  1. 下載 Flutter SDK 套件

    下載以下安裝套件,以取得最新穩定版本的 Flutter SDK(Flutter 軟體開發套件)。

    (loading...)

  2. 建立儲存 SDK 的資料夾

    建立或尋找一個資料夾,用來存放解壓縮後的 SDK。 建議在 ~/develop/ 目錄下建立並使用該資料夾。

  3. 解壓縮 SDK

    將你下載的 SDK 套件解壓縮到你想要存放 Flutter SDK 的目錄中。

    1. 複製以下指令。
    2. <sdk_zip_path> 替換為你下載的套件檔案路徑。
    3. <destination_directory_path> 替換為你希望解壓縮後 SDK 所在的資料夾路徑。
    4. 在你偏好的終端機中執行編輯後的指令。
    tar -xf <sdk_zip_path> -C <destination_directory_path>

    例如,假設你已將 Flutter 3.29.3 的 bundle 檔案下載到 ~/Downloads 目錄,並希望將解壓縮後的 SDK 儲存到 ~/develop 目錄:

    tar -xf ~/Downloads/flutter_linux_3.29.3-stable.tar.xz -C ~/develop/

將 Flutter 加入您的 PATH

#

現在您已下載好 SDK, 請將 Flutter SDK 的 bin 目錄加入您的 PATH 環境變數中。 將 Flutter 加入您的 PATH 之後,您就能在終端機與 IDE 中 使用 flutterdart 命令列工具。

  1. Determine your Flutter SDK installation location

    Copy the absolute path to the directory that you downloaded and extracted the Flutter SDK into.

  2. Navigate to the environment variables settings

    1. Press Windows + Pause.

      If your keyboard lacks a Pause key, try Windows + Fn + B.

      The System > About dialog opens.

    2. Click Advanced System Settings > Advanced > Environment Variables....

      The Environment Variables dialog opens.

  3. Add the Flutter SDK bin to your path

    1. In the User variables for (username) section of the Environment Variables dialog, look for the Path entry.

    2. If the Path entry exists, double-click it.

      The Edit Environment Variable dialog should open.

      1. Double-click inside an empty row.

      2. Type the path to the bin directory of your Flutter installation.

        For example, if you downloaded Flutter into a develop\flutter folder inside your user directory, you'd type the following:

        %USERPROFILE%\develop\flutter\bin
      3. Click the Flutter entry you added to select it.

      4. Click Move Up until the Flutter entry sits at the top of the list.

      5. To confirm your changes, click OK three times.

    3. If the entry doesn't exist, click New....

      The Edit Environment Variable dialog should open.

      1. In the Variable Name box, type Path.

      2. In the Variable Value box, type the path to the bin directory of your Flutter installation.

        For example, if you downloaded Flutter into a develop\flutter folder inside your user directory, you'd type the following:

        %USERPROFILE%\develop\flutter\bin
      3. To confirm your changes, click OK three times.

  4. Apply your changes

    To apply this change and get access to the flutter tool, close and reopen all open command prompts, sessions in your terminal apps, and IDEs.

  5. Validate your setup

    To ensure you successfully added the SDK to your PATH, open command prompt or your preferred terminal app, then try running the flutter and dart tools.

    flutter --version
    dart --version

    If either command isn't found, check out Flutter installation troubleshooting.

  1. Determine your Flutter SDK installation location

    Copy the absolute path to the directory that you downloaded and extracted the Flutter SDK into.

  2. Open or create the Zsh environment variable file

    If it exists, open the Zsh environment variable file ~/.zprofile in your preferred text editor. If it doesn't exist, create the ~/.zprofile file.

  3. Add the Flutter SDK bin to your path

    At the end of your ~/.zprofile file, use the built-in export command to update the PATH variable to include the bin directory of your Flutter installation.

    Replace <path-to-sdk> with the path to your Flutter SDK installation.

    bash
    export PATH="<path-to-sdk>/bin:$PATH"

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd add the following to the file:

    bash
    export PATH="$HOME/develop/flutter/bin:$PATH"
  4. Save your changes

    Save, then close, the ~/.zprofile file you edited.

  5. Apply your changes

    To apply this change and get access to the flutter tool, close and reopen all open Zsh sessions in your terminal apps and IDEs.

  6. Validate your setup

    To ensure you successfully added the SDK to your PATH, open a Zsh session in your preferred terminal, then try running the flutter and dart tools.

    flutter --version
    dart --version

    If either command isn't found, check out Flutter installation troubleshooting.

  1. Determine your Flutter SDK installation location

    Copy the absolute path to the directory that you downloaded and extracted the Flutter SDK into.

  2. Determine your default shell

    If you don't know what shell you use, check which shell starts when you open a new console window.

    echo $SHELL
  3. Add the Flutter SDK bin to your path

    To add the bin directory of your Flutter installation to your PATH:

    1. Expand the instructions for your default shell.
    2. Copy the provided command.
    3. Replace <path-to-sdk> with the path to your Flutter SDK install.
    4. Run the edited command in your preferred terminal with that shell.

    Expand for bash instructions
    echo 'export PATH="<path-to-sdk>:$PATH"' >> ~/.bash_profile

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'export PATH="$HOME/develop/flutter/bin:$PATH"' >> ~/.bash_profile
    Expand for zsh instructions
    echo 'export PATH="<path-to-sdk>/bin:$PATH"' >> ~/.zshenv

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'export PATH="$HOME/develop/flutter/bin:$PATH"' >> ~/.zshenv
    Expand for fish instructions
    fish_add_path -g -p <path-to-sdk>/bin

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    fish_add_path -g -p ~/develop/flutter/bin
    Expand for csh instructions
    echo 'setenv PATH "<path-to-sdk>/bin:$PATH"' >> ~/.cshrc

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'setenv PATH "$HOME/develop/flutter/bin:$PATH"' >> ~/.cshrc
    Expand for tcsh instructions
    echo 'setenv PATH "<path-to-sdk>/bin:$PATH"' >> ~/.tcshrc

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'setenv PATH "$HOME/develop/flutter/bin:$PATH"' >> ~/.tcshrc
    Expand for ksh instructions
    echo 'export PATH="<path-to-sdk>/bin:$PATH"' >> ~/.profile

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'export PATH="$HOME/develop/flutter/bin:$PATH"' >> ~/.profile
    Expand for sh instructions
    echo 'export PATH="<path-to-sdk>/bin:$PATH"' >> ~/.profile

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'export PATH="$HOME/develop/flutter/bin:$PATH"' >> ~/.profile
  4. Apply your changes

    To apply this change and get access to the flutter tool, close and reopen all open shell sessions in your terminal apps and IDEs.

  5. Validate your setup

    To ensure you successfully added the SDK to your PATH, open your preferred terminal with your default shell, then try running the flutter and dart tools.

    flutter --version
    dart --version

    If either command isn't found, check out Flutter installation troubleshooting.

  1. Determine your Flutter SDK installation location

    Copy the absolute path to the directory that you downloaded and extracted the Flutter SDK into.

  2. Add the Flutter SDK bin to your path

    To add the bin directory of your Flutter installation to your PATH:

    1. Copy the following command.
    2. Replace <path-to-sdk> with the path to your Flutter SDK install.
    3. Run the edited command in your preferred terminal.
    echo 'export PATH="<path-to-sdk>:$PATH"' >> ~/.bash_profile

    For example, if you downloaded Flutter into a develop/flutter folder inside your user directory, you'd run the following:

    echo 'export PATH="$HOME/develop/flutter/bin:$PATH"' >> ~/.bash_profile
  3. Apply your changes

    To apply this change and get access to the flutter tool, close and reopen all open Zsh sessions in your terminal apps and IDEs.

  4. Validate your setup

    To ensure you successfully added the SDK to your PATH, open a Zsh session in your preferred terminal, then try running the flutter and dart tools.

    flutter --version
    dart --version

    If either command isn't found, check out Flutter installation troubleshooting.

繼續您的 Flutter 之旅

#

現在您已成功安裝 Flutter, 請至少設定一個目標平台的開發環境, 以繼續您的 Flutter 之旅。