setPreviewSize method

Future<void> setPreviewSize(
  1. int width,
  2. int height
)

Sets the dimensions for preview pictures.

If the preview has already started, applications should stop the preview first before changing preview size. The sides of width and height are based on camera orientation. That is, the preview size is the size before it is rotated by display orientation. So applications need to consider the display orientation while setting preview size. For example, suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size. Exception on 176x144 (QCIF) resolution: Camera devices usually have a fixed capability for downscaling from larger resolution to smaller, and the QCIF resolution sometimes is not fully supported due to this limitation on devices with high-resolution image sensors. Therefore, trying to configure a QCIF preview size with any picture or video size larger than 1920x1080 (either width or height) might not be supported, and Camera.setParameters might throw a PlatformException if it is not.

Implementation

Future<void> setPreviewSize(int width, int height) {
  return _channel.$setPreviewSize(this, width, height);
}