applySplash function

Future<void> applySplash({
  1. String? imageSource,
  2. String? color,
  3. String? gravity,
  4. String? iosContentMode,
  5. String? iosBackgroundContentMode,
  6. YamlMap? android12AndAbove,
  7. String? backgroundImageSource,
  8. String? backgroundImageGravity,
  9. String? darkImage,
  10. String? darkColor,
  11. String? darkGravity,
  12. String? darkBackgroundImageSource,
})

Applies the splash screen on Android and iOS using details from the YAML file.

Implementation

Future<void> applySplash({
  String? imageSource,
  String? color,
  String? gravity,
  String? iosContentMode,
  String? iosBackgroundContentMode,
  YamlMap? android12AndAbove,
  String? backgroundImageSource,
  String? backgroundImageGravity,
  String? darkImage,
  String? darkColor,
  String? darkGravity,
  String? darkBackgroundImageSource,
}) async {
  final iosSkipReasons = <String>[];

  if (darkImage != null && imageSource == null) {
    iosSkipReasons.add(
      'For iOS, image is required when image_dark is provided. '
      'Add image to provide the base Any appearance asset.',
    );
  }

  if (darkBackgroundImageSource != null && backgroundImageSource == null) {
    iosSkipReasons.add(
      'For iOS, background_image is required when background_image_dark is provided. '
      'Add background_image to provide the base Any appearance asset.',
    );
  }

  if (iosSkipReasons.isNotEmpty) {
    log('Skipping iOS splash generation: ${iosSkipReasons.join(' ')}');
    log('Continuing with Android generation.');
  } else {
    await generateIosImages(
      imageSource: imageSource,
      color: color,
      backgroundImage: backgroundImageSource,
      iosContentMode: iosContentMode,
      iosBackgroundContentMode: iosBackgroundContentMode,
      darkImageSource: darkImage,
      darkColor: darkColor,
      darkBackgroundImage: darkBackgroundImageSource,
    );
  }

  await applyAndroidSplashImage(
    imageSource: imageSource,
    color: color,
    gravity: gravity,
    android12AndAbove: android12AndAbove,
    backgroundImageSource: backgroundImageSource,
    backgroundImageGravity: backgroundImageGravity,
    darkImage: darkImage,
    darkColor: darkColor,
    darkGravity: darkGravity,
    darkBackgroundImageSource: darkBackgroundImageSource,
  );
}