getRotation method

  1. @override
Future<int> getRotation()
override

Returns the clockwise rotation in degrees (0, 90, 180, or 270) that must be applied to the camera preview and any coordinates derived from captureFrame so they appear upright for the current device orientation.

iOS reports a non-zero value on phones (the sensor is physically landscape and its buffers reach Dart unrotated). On Android the display pipeline already orients the preview texture (the same behavior the official camera plugin relies on), so this is typically 0; captured frames are rotated natively to match. Desktops and web report 0. The preview itself is never rotated at the pixel level on iOS/desktop — apply the returned angle to the preview Widget and to decoded result coordinates in Dart.

Implementation

@override
Future<int> getRotation() async {
  // Browsers auto-rotate the getUserMedia stream to match the page, so the
  // preview is already upright.
  return 0;
}