An example of how to package a Flutter application as a Flatpak for distribution on Linux, using the default counter example app.
Note: Building a flatpak should be done in a predictable environment or it may fail.
Set up Flathub, and choose one:
Use the VSCode dev container provided in this repo that will run everything through Docker
-
Install the Dev Containers extension
-
Open this directory in VSCode.
-
Accept the prompt to re-open in the dev container, or from the Command Palette search for
Reopen in Container
There is a GitHub action for this purpose, which is demonstrated in this repo. This action's page also lists the docker containers it uses.
If you fork this example repo you can run the example workflow, and install the
.flatpak
file it generates withflatpak install <path-to-.flatpak>
.
Install flatpak and flatpak-builder
On ubuntu:
sudo apt install flatpak flatpak-builder
Add the FlatHub repo:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Install flatpak build dependencies:
flatpak install -y org.freedesktop.Sdk/x86_64/22.08
flatpak install -y org.freedesktop.Platform/x86_64/22.08
flatpak install -y flathub org.freedesktop.appstream-glib
We have two directories that each represent what would be separate git repositories for a real project:
counter_app is the Flutter app, view the README there for info on configuration and building.
flathub_repo is separate from the Flutter app and is where the Flatpak is
assembled, view the README there for info on configuration, building, and
publishing of the flatpak after building the counter_app
.