vijaycreations
Published in

vijaycreations

Dynamically change app launcher icon in flutter

In this article we will discuss about how to dynamically change multiple app launcher icons during run-time in our flutter apps.

Add the following dependency in the pubspec.yaml file.

Consider we have the basic UI (containing the images and elevated button widgets) ready.

Now we need to write the logic for changing the app launcher icon, inside the onpress event [changeAppIcon{}] of the elevated button widget.

With this we completed the coding part for configuring the dynamic app icons.

Now to get the feature working, we need to add some changes in info.plist file which is present inside the project’s ios folder.

Therefore we need to open the project in xCode by right clicking on the ios folder.

⚠️ (Note: this feature targets iOS platforms, so we need a macOS device to set it up).

After opening the project in xCode, try adding the app icon images inside the Runner/Runner folder as shown below.👇

Next we need to set the info.plist file (follow the steps given below).

👉 Add Icon files (iOS 5) to the Information Property List.

👉 Add CFBundleAlternateIcons as a dictionary, inside the icon files(ios 5) created above.

👉 Create 3 dictionaries under CFBundleAlternateIcons, with the name similar to the icon images file name (in our case it is icon1, icon2 and icon3)

👉 For each dictionary (icon1, icon2 and icon3), two properties — UIPrerenderedIcon and CFBundleIconFiles need to be created.

👉 Finally change the CFBundleIconFiles into and an array and add item0 with the value as icon1, icon2 and icon3 for respective dictionaries.

Now run the cmds,

flutter cleanflutter pub get

Well that’s it. 🎉 Run the code to see it in action.🥳

Refer my video tutorial for complete guide:👉 https://www.youtube.com/watch?v=412lSuyUJ_4

Get the complete source code here:👉 https://github.com/vijayinyoutube/dynamic_app_icon_app

--

--

A list of Flutter Tutorials and app templates

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vijay R

Hai👋 I’m a flutter developer experienced in designing and developing stunning mobile apps. Reach out for freelance projects: vijaycreations02@gmail.com