Packaging and Distributing Flutter Desktop Apps : The Missing Guide for Open Source & Indie Developers — Creating Windows .exe installer [Part 2 of 3]
by Ashita Prasad (LinkedIn, Twitter), fluttergems.dev
Articles in this series:
- Introduction & creating macOS
.app
&.dmg
— Part 1 of 3 - Creating Windows
.exe
installer — Part 2 of 3 [This article] - Creating Linux Debian (
.deb
) & RPM (.rpm
) builds — Part 3 of 3
In the previous article, we uncovered the motivation behind creating this step-by-step guide for packaging and distributing Flutter desktop apps the “indie” way or the open source way. We covered the entire process we follow (step-by-step) to build the macOS distribution (.dmg
) of API Dash, an open source alternative to Postman that we have built completely using Flutter (GitHub repo👇).
In this article, we will go through the step-by-step process of creating a Windows executable file (.exe
) to distribute your Flutter desktop app for Windows.
Packaging & Publishing Flutter Desktop App for Windows
To learn how to build & publish msix build for Windows check out the official docs on integration & deployment.
Step 1
Download & install the latest version of Visual Studio (Community edition is Free) from here.
Download and install the Inno setup software (link) which will help us create the Windows executable file.
Step 2
Open your Flutter project in VS Code & execute the build command in the terminal.
flutter build windows --release
It will create the .exe
file along with some .dll
files & the data
folder containing assets in the following location:
C:\\path\to\project\build\windows\runner\Release
Step 3
The above files are not sufficient to distribute and run the app as Visual C++ runtime libraries are also required in the target (end-user) machine.
To ensure the availability of the required libraries, you can copy the following Visual Studio .dll
files:
msvcp140.dll
msvcp140_1.dll
msvcp140_2.dll
vcruntime140.dll
vcruntime140_1.dll
from the below path (or similar path according to your Visual Studio version):
C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\
Redist\MSVC\14.34.31931\x64\Microsoft.VC143.CRT\
and place it alongside the other .dll
files in the project build release folder.
Step 4
Launch Inno Setup and create a new script using script wizard by clicking OK
.
Click Next
on the Welcome screen shown below:
Enter the application details like name, version, publisher name and website as shown below:
Select the destination base folder & application folder name as shown below. You can also allow the user to change this location.
Click Browse
and select the main .exe
file that we had generated in Step 2.
Click Add file(s)…
and select all the .dll
files in the Release
folder.
Click Add folder…
and add the data
folder that was created earlier. This folder contains all the assets like fonts, images, etc.
Scroll down the list & select the data folder path and click on Edit…
button.
It is important to ensure that the destination sub-folder has the same name data
otherwise the app wont run after installation as all contents of the folder are dispersed outside. So, enter the name of the Destination subfolder as data
and click OK
.
Now, click on Next
to proceed as shown below.
In case you want to associate a file type to open with this application, specify the file type name and extension as shown below.
Specify if users can create shortcuts as shown below.
In case your application has a Software License file, you can add the path to the license.txt as shown below. It can be any kind of license including open source license such as MIT, Apache-2, GPL, etc. The user will be shown the license while installing the application. Also, you can provide some information to be shown before & after software installation.
Specify the install mode or allow the user to choose the install mode for the application as shown below.
Specify the setup languages that should be included.
Specify the output folder name along with the custom setup icon file. This will the path of the compiled exe
file.
Click on Next
and then Finish
to complete the Script Wizard as shown below.
Step 5
Once the Script Wizard is complete, an inno setup script is generated. This script has to be run to build the installer. You are prompted to compile the sript as shown below. Go ahead and press Yes
.
In case you closed the prompt to make any modification to the script, you can click on the Run
button as shown below to generate the windows .exe
installer file.
This script can be easily edited and executed to create Windows installers for future app versions.
Step 6
The .exe
file can be located in the output directory we specified in the previous step. The logo of the setup file is also the custom logo we selected in the previous step.
Simply, double click to install the app on Windows. The installation process starts with the license screen as shown below.
Step 7
To distribute the app via GitHub, you can create a new release and attach the .exe
file as shown below.
Once the release is published, the exe
installer file will be available for download to all Windows users.
Closing Notes
In this article, we learnt how you can create a Windows executable (.exe
) file to distribute your Flutter desktop app the “indie” or open source way. You can check out the other article in this series to learn how to do the same for other desktop platforms.
- Introduction & creating macOS
.app
&.dmg
— Part 1 of 3 - Creating Linux Debian (
.deb
) & RPM (.rpm
) builds — Part 3 of 3
In case you have any doubts or queries please feel free to comment below or drop in our Discord Server.
This article is brought to you by Flutter Gems, a curated list of top Dart and Flutter packages that are categorized based on functionality. Do check it out below 👇