Posted in

Flutter Desktop – How to Change App Icon for Windows MacOS and Linux

How to Change App Icon for Windows MacOS and Linux
How to Change App Icon for Windows MacOS and Linux

A polished desktop application needs a custom icon. It’s a core part of your app’s brand and the first thing users see. By default, Flutter gives you its logo, but changing it is a crucial step before release.

The process is different for each operating system and happens in the native project folders, not in your Dart code. This guide will show you the easy, automated way and the manual, platform-specific methods for Windows, macOS, and Linux.

The Easy Way (Recommended): Using a Package

The most efficient way to set your desktop app icons is with the flutter_launcher_icons package. It’s a popular tool that automates the entire process of generating and placing the correct icon files for all platforms.

Step 1: Add the Package

Add flutter_launcher_icons as a dev dependency in your pubspec.yaml file:

YAML

dev_dependencies:
  flutter_launcher_icons: ^0.13.1 # Use the latest version
Dart

Step 2: Configure Your Icon

In the same pubspec.yaml file, add a new section to configure the package. You’ll need a high-resolution icon image (e.g., a 1024×1024 PNG) placed in your project, typically in an assets folder.

YAML

flutter_launcher_icons:
  # The path to your master icon image
  image_path: "assets/icon/app_icon.png" 

  # Windows specific settings
  windows:
    generate: true # Enable icon generation for Windows
    icon_size: 48 # The size of the icon file

  # MacOS specific settings
  macos:
    generate: true # Enable icon generation for MacOS

  # Linux specific settings
  linux:
    generate: true # Enable icon generation for Linux
Dart

Step 3: Run the Package

Save the pubspec.yaml file, and then run the following commands in your terminal:

Bash

# First, get the new package
flutter pub get

# Then, run the package to generate the icons
flutter pub run flutter_launcher_icons
Dart

That’s it! The package will automatically create the correctly formatted files (.ico for Windows, .icns for macOS, .png for Linux) and place them in the right directories.

The Manual Method (Platform by Platform)

If you prefer not to use a package or need to troubleshoot, here’s how to change the icons manually for each OS.

🖥️ Windows

  1. Create an .ico file: Windows uses a special .ico format. You cannot just rename a PNG. Use an online tool or a graphics editor to convert your high-resolution PNG icon into an .ico file.
  2. Replace the file: Navigate to the /windows/runner/resources/ directory in your Flutter project.
  3. Replace app_icon.ico with the new .ico file you created. Ensure it has the exact same name.

🍎 macOS

  1. Create an .icns file: macOS uses the .icns format. Like with Windows, you’ll need to use an online converter or a tool like macOS’s built-in iconutil to create this file from your source PNG.
  2. Navigate to the asset catalog: Go to the /macos/Runner/Assets.xcassets/AppIcon.appiconset/ directory.
  3. Replace the icon files: You can either replace the existing AppIcon.icns file with your own, or replace all the individual PNG files of different sizes within that folder. Replacing the .icns file is often simpler.

🐧 Linux

  1. Prepare a .png file: Linux typically uses standard PNG files for icons. No special conversion is needed.
  2. Navigate to the icons directory: Go to the /linux/my_application/data/icons/ directory. (The my_application folder name might vary based on your project).
  3. Replace the image: Replace the existing PNG icon file(s) with your own icon, keeping the dimensions and names the same.

✅ Important: Rebuild Your App

After changing the icon using either method, you must perform a full rebuild of your application to see the change. Hot Reload will not work.

Close your app if it’s running, and then execute:

Bash

# Clean the previous build
flutter clean

# Run the app again for your target platform
flutter run -d windows
# or -d macos, or -d linux
Dart

Your desktop app should now proudly display its new custom icon!

Flutter Stuff Is A Team Of Passionate Flutter Developers On A Mission To Empower The Community. We Share Our Expertise And Insights Through Comprehensive Guides, Tutorials, And Resources, Making Flutter Mobile App Development Accessible And Enjoyable For Everyone.

Leave a Reply