addIcons method

void addIcons({
  1. required String name,
  2. required String fileName,
  3. List<String>? parameters,
  4. String? workingDir,
  5. List<String>? hotKey,
  6. String? comment,
  7. String? iconFilename,
  8. String? iconIndex,
  9. String? appUserModelID,
  10. Uuid? appUserModelToaseActivatorCLSID,
  11. List<IconFlag>? flags,
  12. List<String>? tasks,
})

Adds an Icon entry to the Inno Setup script.

name, fileName, and parameters are required. workingDir, hotKey, comment, iconFilename, iconIndex, appUserModelID, appUserModelToaseActivatorCLSID, and flags are optional. tasks is optional.

Implementation

void addIcons({
  required String name,
  required String fileName,
  List<String>? parameters,
  String? workingDir,
  List<String>? hotKey,
  String? comment,
  String? iconFilename,
  String? iconIndex,
  String? appUserModelID,
  Uuid? appUserModelToaseActivatorCLSID,
  List<IconFlag>? flags,
  List<String>? tasks,
}) {
  String iconsPart = [
    'Name: "$name"',
    'Filename: "$fileName"',
    if (parameters != null && parameters.isNotEmpty)
      'Parameters: "${parameters.join(' ')}"',
    if (workingDir != null) 'WorkingDir: "$workingDir"',
    if (hotKey != null && hotKey.isNotEmpty) 'HotKey: "${hotKey.join('+')}"',
    if (comment != null) 'Comment: "$comment"',
    if (iconFilename != null) 'IconFilename: "$iconFilename"',
    if (iconIndex != null) 'IconIndex: "$iconIndex"',
    if (appUserModelID != null) 'AppUserModelID: "$appUserModelID"',
    if (appUserModelToaseActivatorCLSID != null)
      'AppUserModelToastActivatorCLSID: "$appUserModelToaseActivatorCLSID"',
    if (flags != null && flags.isNotEmpty) 'Flags: "${flags.join(' ')}"',
    if (tasks != null && tasks.isNotEmpty) 'Tasks: ${tasks.join(' ')}'
  ].join('; ');

  if (_icons.isEmpty) {
    _icons.writeln('[ICONS]');
    _icons.writeln(iconsPart);
  } else {
    _icons.writeln(iconsPart);
  }
}