Change the launcher icon

4. To change the launcher icon (app icon) in a Flutter project, you
can follow these steps:

4.1. Prepare Your New Icons:

First, prepare the new launcher icon images in the required sizes. Android and iOS have different size requirements. You typically need icons in various sizes to support different screen densities.

Android:

For Android, you need to replace the existing launcher icon files with your new ones. The launcher icons for Android are stored in the mipmap folders inside the android/app/src/main/res directory.

Replace the existing icon files (ic_launcher.png) in the mipmap folders with your new icon files. Make sure to maintain the same file names and sizes.

You may need to replace icons in various drawable folders for different screen densities (e.g., mipmap-hdpi, mipmap-mdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi).

iOS:

For iOS, you need to replace the existing icon files with your new ones. The icons for iOS are stored in the Assets.xcassets directory in the ios/Runner directory.

Open your Flutter project in Xcode by navigating to the ios directory and opening the .xcworkspace file with Xcode.

In Xcode, navigate to Runner > Assets.xcassets.

Replace the existing AppIcon with your new icon files. You’ll typically find different sizes labelled for various devices (e.g., iPhone, iPad).

4.2. Flutter Launcher Icon Package (Optional):

Alternatively, you can use the flutter_launcher_icons package to automate the process of updating launcher icons. This package allows you to define a single source image and generate the required icons for both Android and iOS.

Install the flutter_launcher_icons package by adding it to your pubspec.yaml file:

dev_dependencies:
flutter_launcher_icons:"^0.9.2"

Run the following command in your terminal to generate launcher icons
based on your configuration:

flutter pub get
flutter pub run flutter_launcher_icons:main

Follow the prompts to configure the package according to your project’s
requirements.

4.3. Test Your Changes:

After replacing the icon files or running the flutter_launcher_icons package, rebuild your Flutter project and run it on both Android and iOS devices/emulators to ensure that the new launcher icon is displayed correctly.