CoverFitTransform.cover constructor
CoverFitTransform.cover({})
Builds a cover-fit transform mapping a sourceWidth x sourceHeight
image onto a viewWidth x viewHeight viewport, preserving aspect ratio
and centering the overflow. Set mirror for a mirrored front-camera
preview.
Implementation
factory CoverFitTransform.cover({
required double sourceWidth,
required double sourceHeight,
required double viewWidth,
required double viewHeight,
bool mirror = false,
}) {
final fit = coverFitScaleOffset(
sourceWidth.round(),
sourceHeight.round(),
viewWidth,
viewHeight,
);
return CoverFitTransform(
scale: fit.scale,
offsetX: fit.offsetX,
offsetY: fit.offsetY,
sourceWidth: sourceWidth,
mirror: mirror,
);
}