在 Debian(Linux) 上用 Flutter 打包应用,常见有几种方式,下面按最常见场景给你说明。
确保已启用 Linux 桌面支持:
flutter config --enable-linux-desktop
flutter doctor
安装依赖(Debian/Ubuntu):
sudo apt update
sudo apt install -y clang cmake ninja-build pkg-config \
libgtk-3-dev liblzma-dev libstdc++-12-dev
flutter build linux --release
构建完成后:
build/linux/x64/release/bundle/
.deb(推荐)linux_packaging(官方实验工具)flutter pub global activate flutter_linux_packaging
flutter linux pack deb
mkdir -p myapp/usr/bin
cp -r build/linux/x64/release/bundle/* myapp/usr/bin/
mkdir -p myapp/DEBIAN
cat > myapp/DEBIAN/control <<EOF
Package: myapp
Version: 1.0.0
Section: utils
Priority: optional
Architecture: amd64
Maintainer: you <you@example.com>
Description: My Flutter App
EOF
dpkg-deb --build myapp
生成:
myapp.deb
安装测试:
sudo dpkg -i myapp.deb
flutter pub global activate appimage_builder
appimage-builder --recipe AppImageBuilder.yml
flutter build apk --release
# 或
flutter build appbundle --release
输出:
build/app/outputs/flutter-apk/app-release.apk
flutter build web
部署 build/web 到 Nginx / Apache。
sudo apt install libgtk-3-dev
sudo apt install clang
| 目标 | 命令 |
|---|---|
| Linux 桌面 | flutter build linux |
| Debian 包 | dpkg-deb |
| Android | flutter build apk |
| Web | flutter build web |
如果你告诉我:
我可以直接给你 一键打包脚本。