下面给你一个在 Debian / Ubuntu 等系统上,把 Flutter 应用打包成 Linux 可执行文件并制作成 .deb 安装包的实用流程。
sudo apt update
sudo apt install -y git curl unzip xz-utils
git clone https://github.com/flutter/flutter.git -b stable ~/flutter
export PATH="$HOME/flutter/bin:$PATH"
flutter doctor
sudo apt install -y \
clang cmake ninja-build pkg-config \
libgtk-3-dev liblzma-dev
flutter config --enable-linux-desktop
flutter create .
flutter build linux
flutter build linux --release
产物位置:
build/linux/x64/release/bundle/
目录结构示例:
bundle/
├── your_app
├── libflutter_linux_gtk.so
├── data/
└── ...
.deb(推荐方式)mkdir -p myapp_deb/opt/myapp
mkdir -p myapp_deb/usr/share/applications
mkdir -p myapp_deb/DEBIAN
cp -r build/linux/x64/release/bundle/* myapp_deb/opt/myapp/
myapp_deb/usr/share/applications/myapp.desktop
[Desktop Entry]
Name=MyApp
Comment=Flutter Linux App
Exec=/opt/myapp/your_app
Icon=/opt/myapp/icon.png
Type=Application
Categories=Utility;
myapp_deb/DEBIAN/control
Package: myapp
Version: 1.0.0
Section: utils
Priority: optional
Architecture: amd64
Depends: libgtk-3-0, libglib2.0-0
Maintainer: you <you@example.com>
Description: A Flutter Linux application
.deb 包dpkg-deb --build myapp_deb myapp_1.0.0_amd64.deb
安装测试:
sudo dpkg -i myapp_1.0.0_amd64.deb
linux_pack / flutter_distributorflutter pub global activate flutter_distributor
flutter_distributor release --targets deb
flutter build linux
appimagetool build/linux/x64/release/bundle
.so → 必须一起打包 bundleArchitecture: amd64如果你愿意,我可以:
直接告诉我你的 Flutter 版本和目标系统即可。