Over the last couple of weeks I figured out how to build a Flutter app from source while being offline, to be able to perform the full app build on Flathub infra. Recently I published an update of my app that is built from source.
To be of benefit to more Flutter developers who publish on Flathub I now generalized and automated parts of the process to come to an offline build, and open sourced this in the form of the flatpak-flutter tool.
Feature Highlights
Use an online build to generate prerequisite files for offline build
Generate flatpak-builder modules, snapshotting a specific version of the Flutter SDK
Generate flatpak-builder sources, parsing pubspec.lock files to create the offline pub-cache
What’s Next?
Be aware that this project is very fresh. To bring it to the next level I would like to get in contact with developers who want to test the tool and turn their app manifest into a source level build. It has the benefit to have both the x86_64 and aarch64 architecture supported without the need for local hardware.
Please create issues on the GitHub project for support and requests. This post is mainly to announce the project and create awareness.
I am working on an app with Flutter, and will need to look in to a Flathub version. I am an experienced Flutter dev and would like to document the process for building Locally on Flathub. Is there a Discord where we can meet? I have a server ready to go.
Also I’d like to translate the overall process for Flutter Flathub to Electron apps as I have an active app in Flathub that is Electron based.
Flathub debugging is also very important, need to see which debugger is best to use with Flutter.
As this is a project I run in my spare time, I can only help with concrete questions. It starts off by looking into it yourself, as you mentioned. The approach I would suggest is:
Create a Flatpak manifest with a binary build of your app
Read the flatpak-flutter documentation
Convert the manifest to a source build
Report any issues you run into on the GitHub of the project.
Version 0.2.0 released
Some changes were made over the last couple of weeks to improve the flatpak-flutter workflow. Previously there were two manifest files to maintain (one for online, one for offline build), now there is just one. This single manifest does all Flutter related stuff in the online fashion, and is then automatically converted into the offline manifest. So from a single input file all related files, needed for the offline build, are generated.
While working together with other developers, who are considering the use of flatpak-flutter, some improvement suggestions were made that are now implemented:
It is no longer necessary that the app to build is in a subdirectory of the project root, the path to the manifest repo can just be specified as a command line parameter.
Besides a yaml manifest, now also a json manifest can be used as input file.
Supporting latest Flutter version
Recently there was a hick-up in the support of the latest Flutter version (3.29.0). A change was made that broke the working of flatpak-flutter. I participated in the solving of this issue, by sharing my workaround and joining the discussion. The issue was picked up by the Flutter team, allowing me to have a proper patch, and today Flutter 3.29.1 is released with the official fix included.
The project is moving, but slowly. To improve visibility I submitted a PR on the Linux | Flutter documentation to include a reference to flatpak-flutter, and Yesterday it was merged
I hope that this makes developers at least aware that there are other options besides the Snap Store.