save method

Future<void> save(
  1. LauncherIconConfig config
)

Saves the provided launcher icon config to the configuration file.

Implementation

Future<void> save(LauncherIconConfig config) async {
  final buffer = StringBuffer();

  buffer.writeln('flutter_launcher_icons:');
  buffer.writeln('  image_path: "${config.imagePath}"');
  buffer.writeln();
  buffer.writeln('  android: ${config.android}');
  buffer.writeln('  ios: ${config.ios}');
  buffer.writeln();

  buffer.writeln(
    '  adaptive_icon_background: "${config.adaptiveBackground}"',
  );
  buffer.writeln(
    '  adaptive_icon_foreground: "${config.adaptiveForeground}"',
  );

  if (config.adaptiveMonochrome != null &&
      config.adaptiveMonochrome!.isNotEmpty) {
    buffer.writeln(
      '  adaptive_icon_monochrome: "${config.adaptiveMonochrome}"',
    );
  }

  buffer.writeln();
  buffer.writeln('  remove_alpha_ios: ${config.removeAlphaIos}');
  buffer.writeln();

  buffer.writeln('  web:');
  buffer.writeln('    generate: ${config.web}');
  buffer.writeln('    image_path: "${config.imagePath}"');
  buffer.writeln('    background_color: "${config.adaptiveBackground}"');
  buffer.writeln('    theme_color: "#000000"');

  await _file.writeAsString(buffer.toString());

  LoggerService.success('$fileName updated.');
}