effectiveCameraScale method
Adjust the proper scale type according to the constraints
.
根据 constraints
获取相机预览适用的缩放。
Implementation
double effectiveCameraScale(
BoxConstraints constraints,
CameraController controller,
) {
final int turns = pickerConfig.cameraQuarterTurns;
final String orientation = controller.value.deviceOrientation.toString();
// Fetch the biggest size from the constraints.
Size size = constraints.biggest;
// Flip the size when the preview needs to turn with an odd count of quarters.
if ((turns.isOdd && orientation.contains('portrait')) ||
(turns.isEven && orientation.contains('landscape'))) {
size = size.flipped;
}
// Calculate scale depending on the size and camera ratios.
double scale = size.aspectRatio * controller.value.aspectRatio;
// Prevent scaling down.
if (scale < 1) {
scale = 1 / scale;
}
return scale;
}