CameraDesktopPlugin class

Desktop implementation of CameraPlatform.

On Linux, uses GStreamer + V4L2. On macOS, uses AVFoundation. On Windows, uses Media Foundation (IMFCaptureEngine).

This plugin registers itself as the camera platform implementation for desktop. When an app depends on both camera and camera_desktop, Flutter automatically calls registerWith, making CameraController work out of the box.

Inheritance
  • Object
  • PlatformInterface
  • CameraDesktopPlugin

Constructors

CameraDesktopPlugin({@visibleForTesting MethodChannel? channel, bool mirrorPreview = true})
Creates a new CameraDesktopPlugin.

Properties

hashCode int
The hash code for this object.
no setterinherited
mirrorPreview bool
Whether to mirror the preview horizontally (like a mirror). Defaults to true. Set to false to show the unmirrored camera image.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

availableCameras() Future<List<CameraDescription>>
Completes with a list of available cameras.
buildPreview(int cameraId) Widget
Builds the camera preview widget for the given cameraId.
createCamera(CameraDescription cameraDescription, ResolutionPreset? resolutionPreset, {bool enableAudio = false}) Future<int>
Creates an uninitialized camera instance and returns the cameraId.
createCameraWithSettings(CameraDescription cameraDescription, MediaSettings mediaSettings) Future<int>
Creates a camera with the given mediaSettings.
dispose(int cameraId) Future<void>
Disposes the camera and releases all associated resources.
getExposureOffsetStepSize(int cameraId) Future<double>
Gets the supported step size for exposure offset for the selected camera in EV units.
getMaxExposureOffset(int cameraId) Future<double>
Gets the maximum supported exposure offset for the selected camera in EV units.
getMaxZoomLevel(int cameraId) Future<double>
Gets the maximum supported zoom level for the selected camera.
getMinExposureOffset(int cameraId) Future<double>
Gets the minimum supported exposure offset for the selected camera in EV units.
getMinZoomLevel(int cameraId) Future<double>
Gets the minimum supported zoom level for the selected camera.
getPlatformCapabilities() Future<Map<String, bool>>
Returns desktop backend capabilities for feature-gating advanced controls.
getSupportedVideoStabilizationModes(int cameraId) Future<Iterable<VideoStabilizationMode>>
Gets a list of video stabilization modes that are supported for the selected camera.
inherited
initializeCamera(int cameraId, {ImageFormatGroup imageFormatGroup = ImageFormatGroup.unknown}) Future<void>
Initializes the camera on the device.
lockCaptureOrientation(int cameraId, DeviceOrientation orientation) Future<void>
No-op on desktop, orientation locking is not applicable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCameraClosing(int cameraId) Stream<CameraClosingEvent>
The camera started to close.
onCameraError(int cameraId) Stream<CameraErrorEvent>
The camera experienced an error.
onCameraInitialized(int cameraId) Stream<CameraInitializedEvent>
The camera has been initialized.
onCameraResolutionChanged(int cameraId) Stream<CameraResolutionChangedEvent>
The camera's resolution has changed. On Web this returns an empty stream.
onDeviceOrientationChanged() Stream<DeviceOrientationChangedEvent>
The ui orientation changed.
onStreamedFrameAvailable(int cameraId, {CameraImageStreamOptions? options}) Stream<CameraImageData>
Returns a stream of CameraImageData frames from the camera.
onVideoRecordedEvent(int cameraId) Stream<VideoRecordedEvent>
The camera finished recording a video.
pausePreview(int cameraId) Future<void>
Pause the active preview on the current frame for the selected camera.
pauseVideoRecording(int cameraId) Future<void>
Pause video recording.
prepareForVideoRecording() Future<void>
No-op on desktop, no preparation needed before recording.
resumePreview(int cameraId) Future<void>
Resume the paused preview for the selected camera.
resumeVideoRecording(int cameraId) Future<void>
Resume video recording after pausing.
setDescriptionWhileRecording(CameraDescription description) Future<void>
Sets the active camera while recording.
setExposureMode(int cameraId, ExposureMode mode) Future<void>
No-op for ExposureMode.auto (the default); throws otherwise.
setExposureOffset(int cameraId, double offset) Future<double>
Sets the exposure offset for the selected camera.
setExposurePoint(int cameraId, Point<double>? point) Future<void>
Sets the exposure point for automatically determining the exposure values.
setFlashMode(int cameraId, FlashMode mode) Future<void>
No-op for FlashMode.off; desktop cameras typically lack flash hardware.
setFocusMode(int cameraId, FocusMode mode) Future<void>
No-op for FocusMode.auto (the default); throws otherwise.
setFocusPoint(int cameraId, Point<double>? point) Future<void>
Sets the focus point for automatically determining the focus values.
setImageFileFormat(int cameraId, ImageFileFormat format) Future<void>
Sets the output image file format for the selected camera.
inherited
setJpegImageQuality(int cameraId, int quality) Future<void>
Sets the JPEG compression quality for still image capture.
inherited
setMirror(int cameraId, bool mirrored) Future<void>
Toggles horizontal mirroring on the live camera feed.
setVideoStabilizationMode(int cameraId, VideoStabilizationMode mode) Future<void>
Sets the video stabilization mode for the selected camera.
inherited
setZoomLevel(int cameraId, double zoom) Future<void>
Set the zoom level for the selected camera.
startVideoCapturing(VideoCaptureOptions options) Future<void>
Starts a video recording and/or streaming session.
startVideoRecording(int cameraId, {Duration? maxVideoDuration}) Future<void>
Starts a video recording.
stopVideoRecording(int cameraId) Future<XFile>
Stops the video recording and returns the file where it was saved.
supportsImageStreaming() bool
Check whether this platform supports image streaming via onStreamedFrameAvailable.
takePicture(int cameraId) Future<XFile>
Captures an image and returns the file where it was saved.
toString() String
A string representation of this object.
inherited
unlockCaptureOrientation(int cameraId) Future<void>
No-op on desktop, orientation locking is not applicable.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

registerWith() → void
Registers this class as the default CameraPlatform implementation.