Orientação gerada a partir de informações públicas. Apenas para referência.
Um plugin do Flutter que permite alterações dinâmicas de ícones de aplicativos e atualizações em lote de números no Android e no iOS. Permite aos desenvolvedores alternar o ícone do aplicativo programaticamente em tempo de execução, útil para personalização de marca, temas sazonais ou preferências do usuário. O plugin suporta gerenciamento de ícones específicos por plataforma e numeração em lote para fins de versão ou promoção. Projetado para integração perfeita com aplicativos Flutter, simplifica a manipulação de ícones sem exigir mudanças no código nativo. Ideal para aplicativos que precisam de flexibilidade visual ou experiências interativas com ícones.
Casos de uso
Alterando o ícone do aplicativo com base na preferência do usuário
Atualizações sazonais ou baseadas em eventos de ícones
Personalização da marca do aplicativo
Testando diferentes variantes de ícones
Troca de ícone de campanha promocional
Principais recursos
Troca dinâmica de ícone em tempo de execução
Suporte para Android e iOS
Gerenciamento de número de lote
Integração simples da API
Nenhum código nativo necessário
Indicado para
Aplicativos com interface do usuário personalizável
Aplicações focadas em marca
Aplicativos orientados por eventos ou sazonais
Ferramentas de desenvolvedor para testes de ícones
Campanhas de marketing ou promocionais
Considerações
Reinicie o aplicativo após alterar o ícone
Suporte limitado em alguns dispositivos mais antigos
O iOS requer configuração adicional
Os ativos de ícones devem ser definidos previamente
Não adequado para mudanças frequentes de ícone
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
flutter_dynamic_icon
A flutter plugin for dynamically changing app icon and app icon batch number in the mobile platform. Supports only iOS (with version > 10.3).
Check out the example directory for a sample app using flutter_dynamic_icon.
iOS Integration
Index
2x - 120px x 120px
3x - 180px x 180px
To integrate your plugin into the iOS part of your app, follow these steps
First let us put a few images for app icons, they are
teamfortress@2x.png, teamfortress@3x.png
photos@2x.png, photos@3x.png,
chills@2x.png, chills@3x.png,
These icons shouldn't be kept in Assets.xcassets folder, but outside. When copying to Xcode, you can select 'create folder references' or 'create groups', if not you will get and error when uploading the build to the AppStore saying: (Thanks to @nohli for this observation)
TMS-90032: Invalid Image Path - - No image found at the path referenced under key 'CFBundleAlternateIcons':...
Here is my directory structure:
Next, we need to setup the Info.plist
Add Icon files (iOS 5) to the Information Property List
Add CFBundleAlternateIcons as a dictionary, it is used for alternative icons
Set 3 dictionaries under CFBundleAlternateIcons, they are correspond to teamfortress, photos, and chills
For each dictionary, two properties — UIPrerenderedIcon and CFBundleIconFiles need to be configured
If the sub-property UINewsstandIcon is showing under Icon files (iOS 5) and you don't plan on using it (it is intended for use with Newstand features), erase it or the app will get rejected upon submission on the App Store
Note that if you need it work for iPads, You need to add these icon declarations in CFBundleIcons~ipad as well. See here for more details.
Here is my Info.plist after adding Alternate Icons
Now, you can call FlutterDynamicIcon.setAlternateIconName with the CFBundleAlternateIcons key as the argument to set that icon.
Dart/Flutter Integration
From your Dart code, you need to import the plugin and use it's static methods:
import'package:flutter_dynamic_icon/flutter_dynamic_icon.dart';
try {
if (awaitFlutterDynamicIcon.supportsAlternateIcons) {
awaitFlutterDynamicIcon.setAlternateIconName("photos");
print("App icon change successful");
return;
}
} onPlatformException {} catch (e) {}
print("Failed to change app icon");
...
// set batch numbertry {
awaitFlutterDynamicIcon.setApplicationIconBadgeNumber(9399);
} onPlatformException {} catch (e) {}
// gets currently set batch numberint batchNumber = FlutterDynamicIcon.getApplicationIconBadgeNumber();
Check out the example app for more details
Screenrecord
Showing App Icon change
Showing Batch number on app icon change in SpringBoard
Reference
This was made possible because this blog. I borrowed a lot of words from this blog.
https://medium.com/ios-os-x-development/dynamically-change-the-app-icon-7d4bece820d2