flutter_launcher_icons
flutter_launcher_icons copied to clipboard
[BUG] launching with flavor (-f) option generates icons for ALL flavors instead of the desired only
:information_source: Info
Version: v0.8.0
:speech_balloon: Description
I have set up 3 flavors in my app: flavor1, flavor2 and flavor3. For flavor1 and flavor2 I already had generated the launcher icons beforehand.
Now I only want to generate icons for flavor3 only. I created an own yaml file for flavor3 called flutter_launcher_icons-flavor3.yaml. I execute the following command in the terminal:
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-flavor3.yaml
and get the output
Flavor: flavor3
• Building iOS launcher icon for flavor3
Flavor: flavor2
• Building iOS launcher icon for flavor2
Flavor: flavor1
• Building iOS launcher icon for flavor1
✓ Successfully generated launcher icons for flavors
The previously generated icons of flavor1 and flavor2 are overwritten. However, I would only expect that icons for flavor3 are generated and the other two are left untouched...
:scroll: Pubspec.yaml
My flutter_launcher_icons-flavor3.yaml file for flavor3:
flutter_icons:
android: false
ios: true
image_path: "assets/logos/flavor3.png"
Future<void> createIconsFromArguments(List<String> arguments) async {
// ... omitted lines ...
// Flavors manangement
var flavors = getFlavors();
var hasFlavors = flavors.isNotEmpty;
// Load the config file
final Map<String, dynamic> yamlConfig =
loadConfigFileFromArgResults(argResults, verbose: true);
/*
-----------------------------------------------------------------------------------
I think the error is here. It looks like if and only if !hasFlavors,
is the if branch run (and thus yamlConfig used). Otherwise,
it generates icons from all flavor files.
There should probably be a check here. If the -f argument
is given, it should go into the if branch, even if flavors are present.
--------------------------------------------------------------------------------------
*/
// Create icons
if ( !hasFlavors ) {
try {
createIconsFromConfig(yamlConfig);
} catch (e) {
stderr.writeln(e);
exit(2);
} finally {
print('\n✓ Successfully generated launcher icons');
}
} else {
try {
for (String flavor in flavors) {
print('\nFlavor: $flavor');
final Map<String, dynamic> yamlConfig = loadConfigFile(flavorConfigFile(flavor), flavorConfigFile(flavor));
await createIconsFromConfig(yamlConfig, flavor);
}
} catch (e) {
stderr.writeln(e);
exit(2);
} finally {
print('\n✓ Successfully generated launcher icons for flavors');
}
}
}
The issue seems to be in createIconsFromArguments (see inserted comment). I think this will be fixed with PR #155...
@personalizedrefrigerator thank you! I hope that your PR will be merged soon 😉
I consider this a feature actually :) It generates icons for all flavors at once, so I don't need to invoke it multiple times
But if you have multiple flavors and only want to generate the icons for one single flavor, it is inconvenient if the others are replaced as well.
I agree with @WieFel , running a single flavor is a must. Additionally, a flag could be added to run all flavors at once.
Still the same problem. Any news on this?
no, it's still the same. for the current active version at least.
Is there any workaround for this?