captureImage method

Future<String?> captureImage({
  1. int? width,
  2. int? height,
  3. CaptureFlash flash = CaptureFlash.OFF,
})

Captures an image from the local participant’s current video stream.

  • This method captures a single frame from the active video stream of the local participant and returns the image encoded as a Base64 string.

Parameters

  • width (optional): The desired width of the captured image in pixels.

  • height (optional): The desired height of the captured image in pixels.

  • flash (optional): CaptureFlash.ON lights the scene first: the camera's torch, or on a front camera the screen, when VideoSDK.setScreenFlash is on. It adds about half a second, and the light goes off even when the capture fails. Defaults to CaptureFlash.OFF.

Returns

  • A String containing the captured image encoded in Base64 format, or null if the image could not be captured.

Example

final base64Image = await room.localParticipant.captureImage(
  width: 640,
  height: 480,
  flash: CaptureFlash.ON,
);

if (base64Image != null) {
  print('Captured image (base64 length): ${base64Image.length}');
}

Implementation

Future<String?> captureImage({
  int? width,
  int? height,
  CaptureFlash flash = CaptureFlash.OFF,
}) =>
    _captureImage(width: width, height: height, flash: flash);