generateAppIcon method

  1. @override
void generateAppIcon()
override

Implementation

@override
void generateAppIcon() {
  logger('Generating app icons');

  // Create alpha layer for xxxhdpi foreground icon (the biggest dimension in android)
  final baseAlphaChannelLayerImage = Image((customSourceImage.width).toInt(), (customSourceImage.width).toInt())
    ..fillBackground(ColorUtils.hexToColor(backgroundColor!).value);

  final resizedBaseForegroundImage = copyResize(
    customSourceImage,
    width: (customSourceImage.width * resizePercentage).toInt(),
    height: (customSourceImage.height * resizePercentage).toInt(),
    interpolation: Interpolation.average,
  );

  // Define paddings for [resizedBaseForegroundImage]
  final paddingX = (baseAlphaChannelLayerImage.width - resizedBaseForegroundImage.width) ~/ 2;
  final paddingY = (baseAlphaChannelLayerImage.height - resizedBaseForegroundImage.height) ~/ 2;

  final foregroundImage = drawImage(baseAlphaChannelLayerImage, resizedBaseForegroundImage, dstX: paddingX, dstY: paddingY);

  for (var template in appIconList) {
    AppImageUtils.saveImage(resFolder: getFullPath(kiOSAppIconsImageFolder), template: template, image: foregroundImage);
  }
}