createResizedImage function
Image
createResizedImage(
- int iconSize,
- Image image, {
- Color? backgroundColor,
})
Implementation
Image createResizedImage(int iconSize, Image image, {Color? backgroundColor}) {
// Letter-box non-square sources when a background color is supplied so the
// source's aspect ratio is preserved instead of squished onto an N×N grid
// (upstream #214). Without a background color we keep the legacy squish
// behavior to stay compatible with existing user output.
final src = backgroundColor != null
? letterBoxToSquare(image, backgroundColor)
: image;
if (src.width >= iconSize) {
return copyResize(
src,
width: iconSize,
height: iconSize,
interpolation: Interpolation.average,
);
} else {
return copyResize(
src,
width: iconSize,
height: iconSize,
interpolation: Interpolation.linear,
);
}
}