flutter-setting-up-on-linux by flutter/skills
npx skills add https://github.com/flutter/skills --skill flutter-setting-up-on-linux要在 Linux 桌面系统上构建和运行 Flutter 应用程序,需要安装所需的 C/C++ 工具链和系统库。Flutter 依赖 dart:ffi 与 Linux 系统调用交互,并依赖 GTK 框架进行 UI 渲染。
基于 Debian/Ubuntu 的发行版所需的软件包:
curl, git, unzip, xz-utils, zipclang, , , 广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
cmakeninja-buildpkg-configlibglu1-mesa, libgtk-3-dev, libstdc++-12-dev按照此顺序工作流程,为 Flutter 桌面开发准备 Linux 主机。
任务进度:
1. 更新并安装依赖项 在 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 clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev
2. 条件性:ChromeOS 设置
apt-get 命令完全更新 Linux 容器。3. IDE 配置 安装 Visual Studio Code、Android Studio 或基于 IntelliJ 的 IDE。安装官方的 Dart 和 Flutter 扩展/插件,以启用语言服务器功能和调试能力。
运行此反馈循环,以确保 Flutter SDK 能正确识别工具链。
任务进度:
1. 运行验证器 执行 Flutter 诊断工具并输出详细信息:
flutter doctor -v
2. 审查并修复(反馈循环)
flutter doctor -v。重复此过程,直到 Linux 工具链部分通过。3. 验证设备可用性 确保 Linux 桌面被识别为有效的部署目标:
flutter devices
预期输出: 必须至少显示一个条目,其平台标记为 linux。
当为 Snap Store 准备发布版本时,需要配置 Snapcraft 构建环境。
任务进度:
1. 安装构建工具
sudo snap install snapcraft --classic
sudo snap install lxd
2. 配置 LXD 初始化 LXD 并将当前用户添加到 lxd 组:
sudo lxd init
sudo usermod -a -G lxd <your_username>
注意:注销并重新登录以应用组更改。
3. 构建 Snap 导航到包含 snap/snapcraft.yaml 文件的项目根目录并执行构建:
snapcraft --use-lxd
snapcraft.yaml 配置为 Snap Store 打包 Flutter Linux 应用程序时,请在 <project_root>/snap/snapcraft.yaml 文件中使用此模板。
name: super-cool-app
version: 0.1.0
summary: Super Cool App
description: Super Cool App that does everything!
confinement: strict
base: core22
grade: stable
slots:
dbus-super-cool-app:
interface: dbus
bus: session
name: org.bar.super_cool_app
apps:
super-cool-app:
command: super_cool_app
extensions: [gnome]
plugs:
- network
slots:
- dbus-super-cool-app
parts:
super-cool-app:
source: .
plugin: flutter
flutter-target: lib/main.dart
每周安装量
1.6K
代码仓库
GitHub 星标数
792
首次出现
12 天前
安全审计
安装于
codex1.5K
opencode1.5K
github-copilot1.5K
gemini-cli1.5K
kimi-cli1.5K
cursor1.5K
To build and run Flutter applications on a Linux desktop, install the required C/C++ toolchain and system libraries. Flutter relies on dart:ffi to interface with Linux system calls and the GTK framework for UI rendering.
Required packages for Debian/Ubuntu-based distributions:
curl, git, unzip, xz-utils, zipclang, cmake, ninja-build, pkg-configlibglu1-mesa, libgtk-3-dev, libstdc++-12-devFollow this sequential workflow to prepare the Linux host for Flutter desktop development.
Task Progress:
1. Update and Install Dependencies Execute the following command to install all required packages on Debian/Ubuntu systems:
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev
2. Conditional: ChromeOS Setup
apt-get commands above before proceeding.3. IDE Configuration Install Visual Studio Code, Android Studio, or an IntelliJ-based IDE. Install the official Dart and Flutter extensions/plugins to enable language server features and debugging capabilities.
Run this feedback loop to ensure the toolchain is correctly recognized by the Flutter SDK.
Task Progress:
1. Run Validator Execute the Flutter diagnostic tool with verbose output:
flutter doctor -v
2. Review and Fix (Feedback Loop)
flutter doctor -v. Repeat until the Linux toolchain section passes.3. Verify Device Availability Ensure the Linux desktop is recognized as a valid deployment target:
flutter devices
Expected Output: At least one entry must display with the platform marked as linux.
When preparing a release build for the Snap Store, configure the Snapcraft build environment.
Task Progress:
1. Install Build Tools
sudo snap install snapcraft --classic
sudo snap install lxd
2. Configure LXD Initialize LXD and add the current user to the lxd group:
sudo lxd init
sudo usermod -a -G lxd <your_username>
Note: Log out and log back in to apply the group changes.
3. Build the Snap Navigate to the project root containing the snap/snapcraft.yaml file and execute the build:
snapcraft --use-lxd
snapcraft.yaml ConfigurationUse this template for the <project_root>/snap/snapcraft.yaml file when packaging a Flutter Linux app for the Snap Store.
name: super-cool-app
version: 0.1.0
summary: Super Cool App
description: Super Cool App that does everything!
confinement: strict
base: core22
grade: stable
slots:
dbus-super-cool-app:
interface: dbus
bus: session
name: org.bar.super_cool_app
apps:
super-cool-app:
command: super_cool_app
extensions: [gnome]
plugs:
- network
slots:
- dbus-super-cool-app
parts:
super-cool-app:
source: .
plugin: flutter
flutter-target: lib/main.dart
Weekly Installs
1.6K
Repository
GitHub Stars
792
First Seen
12 days ago
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
codex1.5K
opencode1.5K
github-copilot1.5K
gemini-cli1.5K
kimi-cli1.5K
cursor1.5K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装