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.
🎥 Video Tutorial
🛠️ Dependencies
Add the following dependency in the pubspec.yaml
file.
🔭 Implementation
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
Check out all my Flutter related blogs here.,👇
Other articles you may like.,
🔵Setting up your Flutter app for publishing in Play Store.
🔴Confetti Animation in Flutter
🟡 Change App Launcher Icon in Flutter
🔴 AnimatedContainer Widget in Flutter
Most popular
Flutter Tutorials
If you found this article useful and wish to support my work, you can consider buying me a ☕️ coffee.👇
If you want to know more about Flutter and various Widgets in Flutter…?🤓 Then visit my channel 👉🏻 vijaycreations🚩
Thanks.,