flutter-environment-setup-linux
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseflutter-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 package updates and installations.
apt-get - If OS is non-Debian (e.g., Fedora, Arch): Halt and inform the user that this skill specifically targets package managers.
apt-get
- 如果操作系统是ChromeOS: 在继续安装软件包之前,需要手动启用Linux支持。
- 如果操作系统是Debian/Ubuntu: 直接进行软件包更新和安装。
apt-get - 如果操作系统是非Debian系(例如Fedora、Arch): 终止流程并告知用户本指南仅针对包管理器。
apt-get
Instructions
操作步骤
-
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)?"
-
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."
-
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 -
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 -
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 -
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
- If VS Code: Provide the snap installation command:
-
Validate the Environment: Run the Flutter diagnostic tool to verify the Linux toolchain and device availability:bash
flutter doctor -v flutter devicesValidate-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 command, and execute it.
sudo apt-get install -y <packages> - If does not list a
flutter devicesplatform device, verify that thelinuxpackage was successfully installed and re-run the validation.libgtk-3-dev
- If the "Linux toolchain" section reports missing dependencies, parse the missing package names, construct a new
-
确定主机操作系统: 请暂停并询问用户: "你是在标准Debian/Ubuntu Linux发行版上搭建这个Flutter环境,还是在Chromebook(ChromeOS)上搭建?"
-
处理ChromeOS前置要求(条件执行): 如果用户表示使用的是Chromebook: 指导用户进入ChromeOS设置,开启"Linux开发环境",并确保其已完全更新。 请暂停并询问用户: "请在Linux支持启用并更新完成后告知我们,以便继续安装软件包。"
-
更新系统软件包: 执行以下命令刷新软件包列表并升级现有软件包:bash
sudo apt-get update -y && sudo apt-get upgrade -y -
安装核心依赖: 安装Flutter在Linux上运行和构建所需的基础依赖项:bash
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa -
安装Linux桌面工具链: 安装编译Linux桌面应用所需的特定C/C++工具链和GTK库:bash
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev -
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
- 如果选择VS Code: 提供snap安装命令:
-
验证环境: 运行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
- 如果"Linux toolchain"部分报告缺少依赖项,解析缺失的软件包名称,构造新的
Constraints
约束条件
- Do not include any external URLs, hyperlinks, or references to external documentation.
- Assume the user has privileges and do not explain basic privilege escalation concepts.
sudo - Do not explain what individual packages (e.g., ,
curl) do; assume the user understands standard Linux development tools.cmake - Strictly use for package management to ensure non-interactive compatibility (
apt-getflags must be present).-y - All terminal commands must be enclosed in code blocks.
bash
- 不要包含任何外部URL、超链接或对外部文档的引用。
- 假设用户拥有权限,无需解释基础的权限提升概念。
sudo - 不要解释单个软件包(例如、
curl)的用途,假设用户了解标准Linux开发工具。cmake - 严格使用进行包管理以确保非交互式兼容性(必须包含
apt-get参数)。-y - 所有终端命令必须包裹在代码块中。
bash