launcher_icon_switcher

Last updated:

0 purchases

launcher_icon_switcher Image
launcher_icon_switcher Images
Add to Cart

Description:

launcher icon switcher

Launcher Icon Switcher #






A Flutter plugin that allows you to dynamically change your app launcher icon.



iOS
 Android









Generating icons #
First you'll need to generate some icons for your app. For that you can use flutter_launcher_icons package. Use CamelCase for your IOS icon names, as these same names will also be used for activity aliases on Android.
Your config might look something like this:
flutter_launcher_icons:
android: "snake_case_icon"
ios: "CamelCaseIcon"
remove_alpha_ios: true
image_path_ios: "assets/launcher/icon-ios.png"
image_path_android: "assets/launcher/icon-android.png"
copied to clipboard
Platform Setup #
For this plugin to work correctly there needs to be some platform specific setup. Check below on how to add support for Android and iOS
Android
Add Activity Aliases #
Once you have generated the Android icons, you can use them as launcher icons by adding activity aliases. To do so, disable your main activity in the AndroidManifest.xml file and add activity-alias elements for each icon like this:
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:enabled="false"
>
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity-alias
android:name=".DefaultIcon"
android:icon="@mipmap/default_icon"
android:enabled="true"
android:exported="true"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
<activity-alias
android:name=".AdditionalIcon"
android:icon="@mipmap/additional_icon"
android:enabled="false"
android:exported="true"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
copied to clipboard
Make sure, that the only enabled alias is the default one.

iOS
Enable IOS Alternate App Icons #
Open your ios project in Xcode, select your app target, go to Build Settings tab and add the following changes:

enable Include All App Icon Assets option
and all your icons to Alternate App Icon Sets
set Primary App Icon Set Name to your default icon



Usage #
Congratulations, you can now use the plugin!!! 🥳🎉🎊
Setup #
First of all you need to initialize the plugin with your icons:
LauncherIconSwitcher().initialize(['DefaultIcon', 'AdditionalIcon', 'OneMoreIcon'], 'DefaultIcon');
copied to clipboard
Retreving current icon #
To know which icon is currently enabled call
LauncherIconSwitcher().getCurrentIcon();
copied to clipboard
Updating launcher icon #
In order to set new icon as your launcher icon call
LauncherIconSwitcher().setIcon('AdditionalIcon');
copied to clipboard
For a more detailed usage example, see here.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.