To change the launcher icon (app icon) for your Flutter app, you can follow these steps:
Step 1: Prepare your app icon image:
Create a square-shaped image file in PNG format with the desired icon design. You will need different sizes of the icon to support various device resolutions. The recommended sizes are 48×48, 72×72, 96×96, 144×144, 192×192, and 512×512 pixels.
Step 2: Replace the default Flutter launcher icon:
- For Android:
- Navigate to the
android/app/src/main/res
directory of your Flutter project. - Replace the default icon files (
ic_launcher.png
) in the corresponding drawable directories (drawable
,drawable-hdpi
,drawable-mdpi
,drawable-xhdpi
,drawable-xxhdpi
,drawable-xxxhdpi
) with your app icon image files. Make sure to keep the same filenames for the icon files.
- Navigate to the
- For iOS:
- Navigate to the
ios
directory of your Flutter project. - Replace the default icon files (
AppIcon.appiconset
) with your app icon image files. Make sure to keep the same filenames for the icon files.
- Navigate to the
Step 3: Update the Flutter project configuration:
- For Android:
- Open the
android/app/src/main/AndroidManifest.xml
file. - Replace the
android:icon
attribute value with"@mipmap/ic_launcher"
. - Save the file.
- Open the
- For iOS:
- Open the
ios/Runner/Info.plist
file. - Add the following lines to the
<dict>
section of the file:
- Open the
<key>CFBundleIconName</key>
<string>AppIcon</string>
Save the file.
Step 4: Clean and rebuild your Flutter project:
Run the following command in your terminal or command prompt:
flutter clean
After the clean process completes, rebuild your project:
flutter build <platform>
Replace with apk for Android or ios for iOS.
Step 5: Run your app on a physical or virtual device to see the updated launcher icon.
That’s it! You have successfully changed the launcher icon for your Flutter app. When you run the app, the new icon will be displayed on the device’s home screen and app launcher.
Remember to follow the design guidelines and requirements for each platform to ensure the best appearance of your app icon on different devices.
Let me know if you have any further questions!