createConfig method
Generates the flutter_launcher_icons.yaml configuration file
for the given Flutter project.
The configuration determines which platforms will have icons generated, the source image path, and optional alpha channel removal for iOS.
Parameters:
projectPath: The root directory of the Flutter project.iconPath: The absolute or relative path to the icon image file (PNG).generateAndroid: Whether to generate Android app icons.generateIos: Whether to generate iOS app icons.removeAlpha: Whether to remove the alpha channel for iOS icons.
Implementation
Future<void> createConfig({
required String projectPath,
required String iconPath,
required bool generateAndroid,
required bool generateIos,
required bool removeAlpha,
}) async {
final configFile = File(
path.join(projectPath, 'flutter_launcher_icons.yaml'),
);
final config = StringBuffer()
..writeln('flutter_launcher_icons:')
..writeln(' android: $generateAndroid')
..writeln(' ios: $generateIos')
..writeln(' image_path: "$iconPath"');
if (removeAlpha) {
config.writeln(' remove_alpha_ios: true');
}
// Disable unused platforms
config
..writeln(' min_sdk_android: 21')
..writeln(' web:')
..writeln(' generate: false')
..writeln(' windows:')
..writeln(' generate: false')
..writeln(' macos:')
..writeln(' generate: false')
..writeln(' linux:')
..writeln(' generate: false');
await configFile.writeAsString(config.toString());
logger.info('✓ Created flutter_launcher_icons.yaml');
}