how to use an specific image icon in flutter local notification?

Issue

the application’s logo is PNG,so in android lollipop this icon convert to be a white square. so i need to use another image in JPG format for flutter local notification.
i have two questions:

first:

where should i put this image?

second:

how could i access this image?

the code is :

 const AndroidInitializationSettings initializationSettingsAndroid =
      AndroidInitializationSettings('@mipmap/ic_launcher');

Solution

You should create a new image with size 48×48. You can have it as png as well as long as there is transparency and image itself is white.

Let’s call this file ic_notification.png

Navigate to your project root directory. You will find android directory. Expand it see following directory in nested order
app
src
main
res
mipmap

if you don’t see mipmap folder or different versions of mipmap folder, like mipmap-xxxdpi or mipmap-hdpi etc, create mipmap folder there and put your icon file in that folder.

On flutter side, replace AndroidInitializationSettings('@mipmap/ic_launcher'); with AndroidInitializationSettings('@mipmap/ic_notification'); (without .png)

You should have different icon for app launcher and notification as they serve different purpose.

Answered By – Rahul

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *