flutter-environment-setup-linux

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

flutter-linux-setup

flutter-linux-setup

Goal

目标

Configures a Linux environment (Debian/Ubuntu or ChromeOS) for Flutter desktop application development by installing required system prerequisites, managing OS-specific configurations, and validating the toolchain.
通过安装所需的系统依赖、处理操作系统特定配置并验证工具链,为Flutter桌面应用开发配置Linux环境(Debian/Ubuntu或ChromeOS)。

Decision Logic

判定逻辑

  • If OS is ChromeOS: Require manual enablement of Linux support before proceeding to package installation.
  • If OS is Debian/Ubuntu: Proceed directly to
    apt-get
    package updates and installations.
  • If OS is non-Debian (e.g., Fedora, Arch): Halt and inform the user that this skill specifically targets
    apt-get
    package managers.
  • 如果操作系统是ChromeOS: 在继续安装软件包之前,需要手动启用Linux支持。
  • 如果操作系统是Debian/Ubuntu: 直接进行
    apt-get
    软件包更新和安装。
  • 如果操作系统是非Debian系(例如Fedora、Arch): 终止流程并告知用户本指南仅针对
    apt-get
    包管理器。

Instructions

操作步骤

  1. Determine the Host Operating System: STOP AND ASK THE USER: "Are you setting up this Flutter environment on a standard Debian/Ubuntu Linux distribution, or on a Chromebook (ChromeOS)?"
  2. Handle ChromeOS Prerequisites (Conditional): If the user indicates they are on a Chromebook: Instruct the user to navigate to their ChromeOS Settings, turn on "Linux development environment", and ensure it is fully updated. STOP AND ASK THE USER: "Please confirm once Linux support is enabled and updated so we can proceed with the package installation."
  3. Update System Packages: Execute the following command to refresh the package lists and upgrade existing packages:
    bash
    sudo apt-get update -y && sudo apt-get upgrade -y
  4. Install Core Prerequisites: Install the base dependencies required for Flutter to operate and build on Linux:
    bash
    sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
  5. Install Linux Desktop Toolchain: Install the specific C/C++ toolchain and GTK libraries required to compile Linux desktop applications:
    bash
    sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev
  6. IDE Configuration Prompt: STOP AND ASK THE USER: "For the best experience, an IDE with Flutter support is recommended. Would you like me to provide the installation commands for Visual Studio Code or Android Studio?"
    • If VS Code: Provide the snap installation command:
      sudo snap install --classic code
    • If Android Studio: Provide the snap installation command:
      sudo snap install android-studio --classic
  7. Validate the Environment: Run the Flutter diagnostic tool to verify the Linux toolchain and device availability:
    bash
    flutter doctor -v
    flutter devices
    Validate-and-Fix: Analyze the output of
    flutter doctor -v
    .
    • If the "Linux toolchain" section reports missing dependencies, parse the missing package names, construct a new
      sudo apt-get install -y <packages>
      command, and execute it.
    • If
      flutter devices
      does not list a
      linux
      platform device, verify that the
      libgtk-3-dev
      package was successfully installed and re-run the validation.
  1. 确定主机操作系统: 请暂停并询问用户: "你是在标准Debian/Ubuntu Linux发行版上搭建这个Flutter环境,还是在Chromebook(ChromeOS)上搭建?"
  2. 处理ChromeOS前置要求(条件执行): 如果用户表示使用的是Chromebook: 指导用户进入ChromeOS设置,开启"Linux开发环境",并确保其已完全更新。 请暂停并询问用户: "请在Linux支持启用并更新完成后告知我们,以便继续安装软件包。"
  3. 更新系统软件包: 执行以下命令刷新软件包列表并升级现有软件包:
    bash
    sudo apt-get update -y && sudo apt-get upgrade -y
  4. 安装核心依赖: 安装Flutter在Linux上运行和构建所需的基础依赖项:
    bash
    sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
  5. 安装Linux桌面工具链: 安装编译Linux桌面应用所需的特定C/C++工具链和GTK库:
    bash
    sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev
  6. IDE配置提示: 请暂停并询问用户: "为获得最佳使用体验,推荐使用支持Flutter的IDE。你需要我提供Visual Studio Code还是Android Studio的安装命令?"
    • 如果选择VS Code: 提供snap安装命令:
      sudo snap install --classic code
    • 如果选择Android Studio: 提供snap安装命令:
      sudo snap install android-studio --classic
  7. 验证环境: 运行Flutter诊断工具验证Linux工具链和设备可用性:
    bash
    flutter doctor -v
    flutter devices
    验证并修复: 分析
    flutter doctor -v
    的输出。
    • 如果"Linux toolchain"部分报告缺少依赖项,解析缺失的软件包名称,构造新的
      sudo apt-get install -y <packages>
      命令并执行。
    • 如果
      flutter devices
      没有列出
      linux
      平台设备,请验证
      libgtk-3-dev
      软件包是否安装成功,然后重新运行验证。

Constraints

约束条件

  • Do not include any external URLs, hyperlinks, or references to external documentation.
  • Assume the user has
    sudo
    privileges and do not explain basic privilege escalation concepts.
  • Do not explain what individual packages (e.g.,
    curl
    ,
    cmake
    ) do; assume the user understands standard Linux development tools.
  • Strictly use
    apt-get
    for package management to ensure non-interactive compatibility (
    -y
    flags must be present).
  • All terminal commands must be enclosed in
    bash
    code blocks.
  • 不要包含任何外部URL、超链接或对外部文档的引用。
  • 假设用户拥有
    sudo
    权限,无需解释基础的权限提升概念。
  • 不要解释单个软件包(例如
    curl
    cmake
    )的用途,假设用户了解标准Linux开发工具。
  • 严格使用
    apt-get
    进行包管理以确保非交互式兼容性(必须包含
    -y
    参数)。
  • 所有终端命令必须包裹在
    bash
    代码块中。