Building a Linux Debian(.deb) file is a key step for developers looking to distribute their software to Linux users. In this blog, we will walk through the process of building a Linux debian (.deb) file from your Flutter project.
To create a Debian package, you first need to activate flutter_distributor using the following command.
dart pub global activate flutter_distributor
You can find detailed information about Flutter Distributor at the following link on pub.dev:
https://pub.dev/packages/flutter_distributor
After activating, you need to create distribute_options.yaml in your root project directory, as shown in the image below:
Now you can add the release specification of the debian build in the distribute_options.yaml as below:
output: dist/
releases:
- name: dev
jobs:
- name: release-dev-linux-deb
package:
platform: linux
target: deb
build_args:
enable-experiment: records
The distribute_options.yaml file is a configuration file that defines how to build and package your software for distribution.
output: dist/:
dist/ is the folder where the built packages will be stored. You can change this to any directory where you want to store the distribution files.
- name: dev:
This defines the name of the release. In this case, the release is called dev, which suggests it is a development build. This name can be used to differentiate different builds, such as development, production, or staging builds.
- name: release-dev-linux-deb:
This is the name of the specific job. The job name release-dev-linux-deb suggests that this job is responsible for creating a Debian package (.deb) for the Linux platform in the development environment.
platform: linux:
The platform specifies the operating system that this job will target. In this case, it is targeting Linux.
target: deb:
The target indicates the type of package that will be generated. In this case, the target is deb, which means a Debian package will be built.
enable-experiment: records:
This argument passes a specific flag to the build process. The flag enable-experiment: records suggests that a feature or experimental functionality named "records" is being enabled during the build.
Now, you need to create a packaging directory inside the linux folder in the project home. Then, create a deb directory inside the packaging directory. After that, add the make_config.yaml file to the deb directory as shown in the image below:
In make_config.yaml, we need to specify all details that are required to create the .deb build like:
* The display name for the application
* The name of the package
* Maintainer information
* App icon path
* Metadata such as app category & keywords
* External dependencies
Like below content:
display_name: Cybrosys Blog
package_name: debconvert
maintainer:
name: Cybrosys Technologies
email: cybrosys@gmail.com
priority: optional
section: x11
installed_size: 15700
dependencies:
- mpv
essential: false
postuninstall_scripts:
- echo "Sorry to see you go."
keywords:
- API
- API Client
generic_name: API Client
categories:
- Development
- Utility
startup_notify: true
Then run the following command to build deb file
flutter_distributor release --name=dev --jobs=release-dev-linux-deb
As a result, you get the terminal output as shown in the image below:
Once you've finished the process in the terminal, head to your project directory using your file explorer. You should see a new folder named "dist," which contains a subfolder called "1.0.0+1." Within that subfolder, you'll find your .deb file, as shown in the image below:
Using flutter_distributor simplifies the process of creating Linux Debian (.deb) packages for your Flutter app, offering an efficient, automated, and customizable solution for seamless distribution to Linux users.
To read more about How to Use Hive to Store & Retrieve Data in a Flutter Application, refer to our blog How to Use Hive to Store & Retrieve Data in a Flutter Application.