AndroidCameraCameraX class

The Android implementation of CameraPlatform that uses the CameraX library.

Inheritance
  • Object
  • PlatformInterface
  • AndroidCameraCameraX

Constructors

AndroidCameraCameraX.new()
Constructs an AndroidCameraCameraX.

Properties

camera ↔ Camera?
The Camera instance returned by the processCameraProvider when a UseCase is bound to the lifecycle of the camera it manages.
getter/setter pair
cameraControl ↔ CameraControl
The CameraControl instance that corresponds to the camera instance.
getter/setter pair
cameraEventStreamController StreamController<CameraEvent>
The controller we need to broadcast the different camera events.
final
cameraImageDataStreamController StreamController<CameraImageData>?
The controller we need to stream image data.
getter/setter pair
cameraInfo ↔ CameraInfo?
The CameraInfo instance that corresponds to the camera instance.
getter/setter pair
cameraIsFrontFacing bool
Whether or not the created camera is front facing.
getter/setter pair
cameraSelector ↔ CameraSelector?
The CameraSelector used to configure the processCameraProvider to use the desired camera.
getter/setter pair
captureOrientationLocked bool
Whether or not the capture orientation is locked.
getter/setter pair
currentFocusMeteringAction ↔ FocusMeteringAction?
The currently set FocusMeteringAction used to enable auto-focus and auto-exposure.
getter/setter pair
deviceOrientationManager → DeviceOrientationManager
Handles retrieving media orientation for a device.
latefinal
enableRecordingAudio bool
Whether or not audio should be enabled for recording video if permission is granted.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
imageAnalysis ↔ ImageAnalysis?
The ImageAnalysis instance that can be configured to analyze individual frames.
getter/setter pair
imageCapture ↔ ImageCapture?
The ImageCapture instance that can be configured to capture a still image.
getter/setter pair
liveCameraState ↔ LiveData<CameraState>?
The LiveData of the CameraState that represents the state of the camera instance.
getter/setter pair
pendingRecording ↔ PendingRecording?
The PendingRecording instance used to create an active Recording.
getter/setter pair
preview ↔ Preview?
The Preview instance that can be configured to present a live camera preview.
getter/setter pair
previewInitiallyBound bool
Whether or not preview has been bound to the lifecycle of the camera by createCamera.
getter/setter pair
processCameraProvider ↔ ProcessCameraProvider?
The ProcessCameraProvider instance used to access camera functionality.
getter/setter pair
proxy ↔ CameraXProxy
Proxy for creating JavaObjects and calling their methods that require testing.
getter/setter pair
recorder ↔ Recorder?
The Recorder instance handling the current creating a new PendingRecording.
getter/setter pair
recording ↔ Recording?
The Recording instance representing the current recording.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sensorOrientationDegrees double
The camera sensor orientation.
getter/setter pair
shouldSetDefaultRotation bool
Whether or not the default rotation for UseCases needs to be set manually because the capture orientation was previously locked.
getter/setter pair
systemServicesManager → SystemServicesManager
Handles access to system resources.
latefinal
torchEnabled bool
Whether or not torch flash mode has been enabled for the camera.
getter/setter pair
videoCapture ↔ VideoCapture?
The VideoCapture instance that can be instantiated and configured to handle video recording
getter/setter pair
videoOutputPath String?
The path at which the video file will be saved for the current Recording.
getter/setter pair
videoPrefix String
The prefix used to create the filename for video recording files.
final
videoRecordingEventStreamQueue → StreamQueue<VideoRecordEvent>
Stream queue to pick up finalized viceo recording events in stopVideoRecording.
final

Methods

availableCameras() Future<List<CameraDescription>>
Returns list of all available cameras and their descriptions.
buildPreview(int cameraId) Widget
Returns a widget showing a live camera preview.
createCamera(CameraDescription description, ResolutionPreset? resolutionPreset, {bool enableAudio = false}) Future<int>
Creates an uninitialized camera instance with default settings and returns the camera ID.
createCameraWithSettings(CameraDescription cameraDescription, MediaSettings? mediaSettings) Future<int>
Creates an uninitialized camera instance and returns the camera ID.
dispose(int cameraId) Future<void>
Releases the resources of the accessed camera.
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.
initializeCamera(int cameraId, {ImageFormatGroup imageFormatGroup = ImageFormatGroup.unknown}) Future<void>
Initializes the camera on the device.
lockCaptureOrientation(int cameraId, DeviceOrientation orientation) Future<void>
Locks the capture orientation.
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.
onDeviceOrientationChanged() Stream<DeviceOrientationChangedEvent>
The ui orientation changed.
onStreamedFrameAvailable(int cameraId, {CameraImageStreamOptions? options}) Stream<CameraImageData>
A new streamed frame is available.
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 the current video recording if it is not null.
prepareForVideoRecording() Future<void>
Prepare the capture session for video recording.
resumePreview(int cameraId) Future<void>
Resume the paused preview for the selected camera.
resumeVideoRecording(int cameraId) Future<void>
Resume the current video recording if it is not null.
setDescriptionWhileRecording(CameraDescription description) Future<void>
Sets the active camera while recording.
setExposureMode(int cameraId, ExposureMode mode) Future<void>
Sets the exposure mode for taking pictures.
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>
Sets the flash mode for the selected camera.
setFocusMode(int cameraId, FocusMode mode) Future<void>
Sets the focus mode for taking pictures.
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
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>
Configures and starts a video recording. Returns silently without doing anything if there is currently an active recording.
stopVideoRecording(int cameraId) Future<XFile>
Stops the video recording and returns the file where it was saved. Throws a CameraException if the recording is currently null, or if the videoOutputPath is null.
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>
Unlocks the capture orientation.

Operators

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

Static Properties

cameraErrorStreamController StreamController<String>
Stream that emits the errors caused by camera usage on the native side.
final
deviceOrientationChangedStreamController StreamController<DeviceOrientationChangedEvent>
Stream that emits the device orientation whenever it is changed.
final
videoRecordingEventStreamController StreamController<VideoRecordEvent>
Stream that emits an event when the corresponding video recording is finalized.
final

Static Methods

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

Constants

exposureCompensationNotSupported → const String
Error code indicating that exposure compensation is not supported by CameraX for the device.
imageFormatJpeg → const int
Constant representing the compressed JPEG image format.
imageFormatYuv420_888 → const int
Constant representing the multi-plane Android YUV 420 image format.
setExposureOffsetFailedErrorCode → const String
Error code indicating that an exposure offset value failed to be set.
zoomStateNotSetErrorCode → const String
Error code indicating a ZoomState was requested, but one has not been set for the camera in use.