March 23, 2025

ikayaniaamirshahzad@gmail.com

Flutter Windows Installer πŸš€ – DEV Community


This README provides instructions for creating a Windows installer for your Flutter application using Inno Setup.




Prerequisites πŸ› οΈ

  1. Build Flutter App for Windows:
    Run the following command in your Flutter project directory to generate the Windows build:
   flutter build windows
Enter fullscreen mode

Exit fullscreen mode

This will generate the build files in the build/windows/runner/Release directory.

  1. Install Inno Setup:
    Download and install Inno Setup from jrsoftware.org or Direct Download Link innosetup-6.4.0.exe.



Steps to Create the Installer πŸ“

  1. Prepare the Build Files
    Copy all files from build/windows/runner/Release to a new directory, e.g., C:\MyFlutterApp\ReleaseFiles.

  2. Create the Inno Setup Script
    Open Inno Setup and create a new script with the following content:

   [Setup]
   AppName=MyFlutterApp
   AppVersion=1.0.0
   DefaultDirName={pf}\MyFlutterApp
   DefaultGroupName=MyFlutterApp
   OutputDir=C:\MyFlutterApp\Installer
   OutputBaseFilename=MyFlutterAppSetup
   Compression=lzma
   SolidCompression=yes

   [Files]
   Source: "C:\MyFlutterApp\ReleaseFiles\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

   [Icons]
   Name: "{group}\MyFlutterApp"; Filename: "{app}\MyFlutterApp.exe"
   Name: "{group}\Uninstall MyFlutterApp"; Filename: "{uninstallexe}"

   [Run]
   Filename: "{app}\MyFlutterApp.exe"; Description: "Launch MyFlutterApp"; Flags: nowait postinstall skipifsilent
Enter fullscreen mode

Exit fullscreen mode

  1. Compile the Script

    • Save the script with a .iss extension, for example, MyFlutterAppInstaller.iss.
    • Open Inno Setup and click Compile to generate the installer in the OutputDir (C:\MyFlutterApp\Installer).
  2. Test the Installer
    Run the generated MyFlutterAppSetup.exe to ensure the installer works as expected.




Customization Options 🎨

  • Update Paths: Change file paths in the script to match your project’s structure.
  • Add Additional Files: Include licenses or documentation by adding entries to the [Files] section.
  • Uninstaller: Inno Setup automatically includes an uninstaller for your application.



Example Project Structure πŸ—‚οΈ

C:\MyFlutterApp
β”œβ”€β”€ ReleaseFiles  # Contains built application files
β”‚   β”œβ”€β”€ MyFlutterApp.exe
β”‚   β”œβ”€β”€ data
β”‚   └── ...
β”œβ”€β”€ Installer      # Generated installer output
β”‚   └── MyFlutterAppSetup.exe
└── MyFlutterAppInstaller.iss  # Inno Setup script
Enter fullscreen mode

Exit fullscreen mode




Conclusion πŸŽ‰

By following these steps, you can create a professional installer for your Flutter Windows application. This will make it easier for users to install and use your app. If you have any questions or feedback, feel free to leave a comment below. Happy coding! πŸ’»



Source link

Leave a Comment