getCanvasTransformation method

CanvasTransformation? getCanvasTransformation(
  1. Preview preview
)

Implementation

CanvasTransformation? getCanvasTransformation(
  Preview preview,
) {
  if (!Platform.isAndroid) {
    return null;
  }

  return switch ((rotation, preview.sensor?.position)) {
    (InputAnalysisImageRotation.rotation0deg, SensorPosition.back) =>
      const CanvasTransformation(
        scale: Point(-1, 1),
        translate: Point(-1, 0),
      ),
    (InputAnalysisImageRotation.rotation180deg, SensorPosition.back) =>
      const CanvasTransformation(
        scale: Point(1, -1),
        translate: Point(0, -1),
      ),
    (InputAnalysisImageRotation.rotation90deg, SensorPosition.back) => null,
    // const CanvasTransformation(
    //   scale: Point(1, -1),
    //   translate: Point(0, -1),
    // ),
    (InputAnalysisImageRotation.rotation0deg, _) ||
    (_, SensorPosition.back) =>
      const CanvasTransformation(
        scale: Point(-1, -1),
        translate: Point(-1, -1),
      ),
    (_, _) => const CanvasTransformation(
        scale: Point(-1, 1),
        translate: Point(-1, 0),
      ),
  };
}