Flutter: Add app icons
To add an app icon to your Flutter app, you can use the
flutter_launcher_icons package, which simplifies the process and automatically generates the required icon sizes for both iOS and Android.
Follow these steps to add an app icon to your Flutter app:
- Add the
flutter_launcher_iconspackage to your
dev_dependencies: flutter_launcher_icons: "^0.9.2"
2. Create a configuration for the package in your pubspec.yaml file. Specify the path to your icon image and the output locations for iOS and Android. Replace
"assets/icon.png" with the path to your icon image file. Make sure the image is square and has a high resolution (at least 1024x1024 pixels).
flutter_icons: image_path: "assets/icon.png" android: true ios: true
3. Run the following command in the terminal to generate the icons:
flutter pub get flutter pub run flutter_launcher_icons:main
This command generates the appropriate sizes and formats for the app icons and places them in the correct directories for both iOS and Android.
iOS: Apple recommends using a 1024x1024 pixel icon. The flutter_launcher_icons package will generate various sizes, including 180x180, 152x152, 120x120, and 76x76 pixels, among others, to ensure compatibility with different iOS devices.
Android: Google recommends using a 512x512 pixel icon. The flutter_launcher_icons package will generate various sizes, including 192x192, 144x144, 96x96, 72x72, and 48x48 pixels, among others, to ensure compatibility with different Android devices and screen densities.
The flutter_launcher_icons package will automatically handle the generation of different sizes, so you only need to provide a high-resolution source image (preferably 1024x1024 pixels).