2

I am trying to add a launcher icon to my flutter app. I have followed all the steps required to create a launcher icon.

This is my pubspec.yaml file

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.9.2

flutter_icons:
  android: true
  image_path_android: "icons/opicon.png"



  image_path: icons/opicon.png
  ios: true
  remove_alpha_ios: true

I have even made a change in android/app/build.gradle file

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.loginpage"
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

I have even got a successful message from flutter

PS D:\Flutter_Projects\loginpage> flutter pub run flutter_launcher_icons:main
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.9.1)
  ════════════════════════════════════════════

• Creating default icons Android
• Overwriting the default Android launcher icon with a new icon
• Overwriting default iOS launcher icon with new icon

✓ Successfully generated launcher icons

But on the emulator, the launcher icon hasn't changed. It still has the default flutter icon.

This is the screenshot of the emulator

image

This is my project folder

enter image description here

The Highlighted folder is where I am having the icon image.

2 Answers2

1

Easiest way to change Launcher Icons,

Go to https://appicon.co/ and add your icon and generate it will give zip file, Extract this file and copy this folder and change in our project Android and Ios folder.

android - LOGINPAGE/android/app/src/main/res

ios - LOGINPAGE/ios/Runner

Then, add dependency

flutter_launcher_icons: ^0.9.2

Add,

flutter_icons:
  android: true
  ios: true
  image_path: "icons/opicon.png"
  remove_alpha_ios: true

run this command on terminal,

flutter pub get

flutter pub run flutter_launcher_icons:main

Then, it's done!

Dev Hingu
  • 161
  • 2
  • I got 2 folders(Android, Assets.xcassets) and 2 images(playstore.png, appstore.png). Should I have all these in a single folder and then add it to "LOGINPAGE/android/app/src/main/res" or should I add only a particular file to "LOGINPAGE/android/app/src/main/res" – RahulKrishna2001 Mar 09 '22 at 01:37
  • First open the **Android** folder and copy all this folder insides it and replace in _LOGINPAGE/android/app/src/main/res_ & then copy Assets.xcassets and replace in _LOGINPAGE/ios/Runner_. Then follow next steps! – Dev Hingu Mar 09 '22 at 02:32
  • Got it, Sir. Thank you so much for helping me out. – RahulKrishna2001 Mar 09 '22 at 02:53
0

In pubspec.yaml file-

dev_dependencies:
  flutter_launcher_icons: "^0.9.2"

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icon/icon.png"

and then run

flutter pub get flutter pub run flutter_launcher_icons:main

After creating icon successful, uninstall app and then flutter run.

Vishal_VE
  • 1,852
  • 1
  • 6
  • 9