createIcons method

  1. @override
void createIcons(
  1. Map<String, dynamic> config,
  2. String? flavor
)
override

Create all icons for the current platform based on the contents of config and the flavor.

Implementation

@override
void createIcons(Map<String, dynamic> config, String? flavor) {
  final String filePath =
      config['image_path_windows'] ?? config['image_path'];
  final Image? image = decodeImage(File(filePath).readAsBytesSync());
  if (image == null) {
    return;
  }
  String iconName;
  final dynamic windowsConfig = config['windows'];
  // If the Windows configuration is a string then the user has specified a new icon to be created
  // and for the old icon file to be kept
  if (flavor != null) {
    final String catalogName = 'app_icon_$flavor';
    printStatus('Building windows launcher icon for $flavor');
    for (IconTemplate template in windowsIcons) {
      _saveNewIcons(template, image, catalogName);
    }
    iconName = windowsDefaultIconName;
    _updateResources(catalogName, flavor);
  } else if (windowsConfig is String) {
    final String newIconName = windowsConfig;
    printStatus('Adding new Windows launcher icon');
    for (IconTemplate template in windowsIcons) {
      _saveNewIcons(template, image, newIconName);
    }
    iconName = newIconName;
    //modifyContentsFile(iconName);
    _updateResources(iconName, flavor);
  }
  // Otherwise the user wants the new icon to use the default icons name and
  // update config file to use it
  else {
    printStatus('Overwriting default windows launcher icon with new icon');
    for (IconTemplate template in windowsIcons) {
      _overwriteDefaultIcons(template, image);
    }
    iconName = windowsDefaultIconName;
    _updateResources('app_icon', flavor);
  }
}