Make .deb package for Ubuntu from a Flutter (Dart) executable

Tonight i finished to implement a Dart application which was implemented using the Flutter framework. After some tests I decided to create a deb package in order to install the application on my linux PC.

On the website there are not enought information to make a deb package and distribute personal software made with Flutter on Ubuntu. So that I decided to write a post in which I will describe step by step how to make a deb package that will allow to distribute our software on linux machines. In this short tutorial I will describe also how to create a shortcut of our software during the installation process of the deb file, so that our application will appear in the start menu of Ubuntu.

A sample of this tutorial could be viewed on GitHub.

So that, let’s start.

First of all we need to build our flutter applciation as release:

flutter build linux --release

After that go to build/linux/release/bundle/

Move all files in a new directory, called for example, myproject/bin. So that in myproject/bin we should have 2 directories: data and lib and a file named myproject which is the executable file.

After that, in the myproject directory, wich is our root directory, we need to create a directory called DEBIAN and another directory called usr.

In the DEBIAN directory we should add a file called control, which is a plain text file.

The file control should contain some information about our deb package. Paste the following content in the control file and change the values of roperties. The Package property should match with the directory and with the executable file located in the bin directory.

Package: myproject
Version: 0.1
Maintainer: Andrei Dodu
Architecture: all
Description: My project sample
Depends:  libgtk-3-0, libblkid1, liblzma5

Next,in the myproject/usr directory create a share forlder and in the share folder create 2 new directories: applications and icons.

In the applications directory create a new file named myproject.desktop and add these rows:

[Desktop Entry]
Name=My Project Name
GenericName=My Project Generic Name
Comment=My procject.

Save the file.

Now go to the root directory. Go up one level, so that:

cd ..

We are ready to create a .deb package. To do that, execute this statement:

dpkg-deb --build myproject

A myproject.deb file will be generated.

Double click on it or execute the following command in order to install the .deb package:

dpkg -i myproject.deb

After the installation a icon will appear in the start menu and so we will be able to open and execute it.