generateMacosCode function

Future<bool> generateMacosCode({
  1. required DesktopSplashConfig config,
  2. required String flavor,
  3. required Directory outputDir,
})

Generates Macos platform-specific code for the native splash screen

Takes a config object containing splash screen configuration, a flavor string to support multiple build flavors, and an output path to override the default location.

Returns true if generation was successful, false otherwise.

Implementation

Future<bool> generateMacosCode({
  required DesktopSplashConfig config,
  required String flavor,
  required Directory outputDir,
}) async {
  // Validate image file exists
  final imageFile = File(config.imagePath);
  if (!imageFile.existsSync()) {
    logger.e('Image file not found: ${config.imagePath}');
    return false;
  }

  // Load and process the image
  final BGRAImage? imageData = await _loadAndProcessImage(config);
  if (imageData == null) {
    return false;
  }

  // Generate the Swift source file
  return _generateSourceFile(
    outputDir: outputDir.path,
    flavor: flavor,
    config: config,
    imageData: imageData,
  );
}