3

I'm new in flutter so please don't kill me if my question is easy.

notification icon doesn't show like this

enter image description here

I put in this path

\android\app\src\main\res\drawable

here is my code for icon:

final settingsAndroid = AndroidInitializationSettings('app_icon'); final settingsIOS = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotification(payload)); final settingsIOSgeneral = IOSInitializationSettings(onDidReceiveLocalNotification: (id, title, body, payload) => onSelectNotificationgeneral(payload)); notifications.initialize(InitializationSettings(settingsAndroid, settingsIOS), onSelectNotification: onSelectNotification);

Can Any one help me please how can I preview my icon in notification ?

Eman Fateen
  • 471
  • 1
  • 5
  • 12

3 Answers3

4

I did the following and it worked for me:

  1. Create a transparent and white notification icon (you can use the following tool: AndroidAssetStudio )

Download the zip folder, unzip and you'll see it contains a res folder with different drawable folders. Copy and paste the contents of the res folder in "android\app\src\main\res" path

Folder Structure

  1. Then open the AndroidManifest.xml file and add the following lines to it:

ic_stat_calendar_today is the name of my notification icon. And each of the drawable folders that have been pasted contain a different size of icon with the same name.

Android Manifest

  1. If you want to change the color of the icon then check the above image. Add the metadata tag after the notification icon tag

  2. Go to "android\app\src\main\res\values" and add a colors.xml file

colors.xml

<color name="colorAccent">#00FF00</color>

I have shared this answer in the following Github chain as well- Solution.

user2549980
  • 363
  • 3
  • 13
1

This could be because the icon image is not transparent -- Try the notification icon generated from this tool. Also check this question Android Push Notifications: Icon not displaying in notification, white square shown instead

Sandeep Chayapathi
  • 1,360
  • 2
  • 11
  • 31
0

generate a transparent icon and then set the color in AndroidNotificationDetails parameter

kk.
  • 2,968
  • 9
  • 30
  • 57
Zahra Jamshidi
  • 225
  • 3
  • 8