NitroCamera class abstract
The main NitroCamera hybrid module.
Use NitroCamera.instance directly, or prefer the higher-level CameraController + CameraPreview Dart API for widget integration.
- Available extensions
- Annotations
-
- @NitroModule.new(ios: NativeImpl.swift, android: NativeImpl.kotlin)
Constructors
Properties
- asAnyNativeObject → AnyNativeObject
-
Available on NitroCamera, provided by the NitroCameraNativeRef extension
no setter -
eventStream
→ Stream<
CameraEvent> -
Stream of session lifecycle / error / interruption events across all open
camera sessions. Buffered (oldest dropped) so events are never lost to a
briefly-slow listener.
no setter
-
frameStream
→ Stream<
CameraFrame> -
Stream of raw camera frames for custom image processing pipelines.
Only active for sessions where enableFrameProcessing was called with 1.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether
disposehas been called on this object.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelRecording(
int textureId) → void - Cancels the current recording and deletes the temporary file.
-
checkDisposed(
) → void -
Throws StateError if
disposehas already been called. Called automatically at the start of every generated method and getter.inherited -
closeCamera(
int textureId) → Future< void> -
configure(
int textureId, CameraConfig config) → Future< ResolvedConfig> -
Applies a batch of live settings to the open session
textureIdin one pass and returns what was actually applied. The declarative analogue of the individual setters above — does NOT reopen the session (device/format/fps changes must go through openCamera). -
dispose(
) → void -
Releases all native resources held by this object.
inherited
-
enableDeviceAvailabilityEvents(
int enabled) → void -
Starts emitting CameraEventType.deviceConnected /
CameraEventType.deviceDisconnected hot-plug events (e.g. USB cameras).
enabled: 1 = on, 0 = off. -
enableFrameProcessing(
int textureId, int enabled) → void -
Enables or disables raw frame delivery to frameStream.
enabled: 1 = on, 0 = off. -
enableOrientationEvents(
int enabled) → void -
Starts emitting CameraEventType.orientationChanged events for physical
device rotation (via the native orientation sensor listener — works even
when the UI orientation is locked).
enabled: 1 = on, 0 = off. -
getAvailableCameraDevices(
) → List< CameraDevice> - Returns a list of all available camera devices.
-
getAvailableCameraDevicesJson(
) → Future< String> -
getCameraPermissionStatus(
) → int - Returns the current camera permission status without prompting.
-
getConcurrentCameraIdsJson(
) → String -
Returns the camera-ID combinations that can stream CONCURRENTLY
(multi-cam), as a JSON array of arrays (e.g.
[["0","1"]]). Empty when unsupported (API < 30 or no combinations). -
getDevice(
int index) → CameraDevice -
getDeviceCount(
) → int -
getMicrophonePermissionStatus(
) → int - Returns the current microphone permission status without prompting.
-
getSessionStateJson(
int textureId) → String - Returns the live session state (running, fps, resolution, pixelFormat) as a JSON object. Useful for diagnostics and UI read-back.
-
lockExposure(
int textureId, int locked) → void -
Locks or unlocks auto-exposure at its current value.
locked: 1 = locked. -
lockFocus(
int textureId, int locked) → void -
Locks or unlocks focus at its current position.
locked: 1 = locked. -
lockWhiteBalance(
int textureId, int locked) → void -
Locks or unlocks white balance at its current gains.
locked: 1 = locked. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDestroy(
) → void -
Called once when
disposeis first invoked. Override to perform cleanup (close file handles, cancel work, etc.).inherited -
onMemoryTrim(
) → void -
Android low-memory signal. Override to release caches or non-critical data.
inherited
-
openCamera(
String deviceId, int width, int height, int fps, int enableAudio) → Future< int> -
Opens the camera identified by
deviceIdand starts streaming frames into a Flutter Texture. Returns the Flutter texture ID. -
pauseRecording(
int textureId) → void - Pauses an active video recording without finalising the file.
-
requestCameraPermission(
) → Future< int> - Requests camera permission from the OS. Returns a PermissionStatus value.
-
requestMicrophonePermission(
) → Future< int> - Requests microphone permission from the OS. Returns a PermissionStatus value.
-
reset(
) → void -
Resets the native camera metadata caches and releases overall hardware locks.
Call this to recover from serious
CAMERA_ERRORor when hardware configuration changes (e.g. plugging in a USB camera). -
resumeRecording(
int textureId) → void - Resumes a paused video recording.
-
setAutoFocus(
int textureId, int mode) → void - Sets the auto-focus mode. Pass an AutoFocusMode value.
-
setDistortionCorrection(
int textureId, int enabled) → void -
Enables or disables lens distortion correction on the capture pipeline
(Camera2
DISTORTION_CORRECTION_MODE, API 28+). No-op when the device doesn't support it.enabled: 1 = on (HIGH_QUALITY), 0 = off. -
setExposure(
int textureId, double value) → void -
Sets exposure compensation.
valueis -1.0 (darkest) to 1.0 (brightest). -
setFilterShader(
int textureId, String shaderSource) → void - Updates the GPU-accelerated filter shader on the camera preview. Pass a valid GLSL Fragment Shader source. The shader should expect:
-
setFlash(
int textureId, int mode) → void - Sets the flash mode for photo capture. Pass a FlashMode value.
-
setFocusPoint(
int textureId, double x, double y) → void -
Locks focus at the normalised point (
x,y) where (0,0) is top-left. -
setFrameFormat(
int textureId, int format) → void -
Sets the pixel format for the frameStream.
format: 0 = YUV_420_888 (Planar), 1 = BGRA_8888 (Interleaved RGB). -
setHdr(
int textureId, int enabled) → void -
Enables or disables HDR capture.
enabled: 1 = on. -
setLowLightBoost(
int textureId, int enabled) → void -
Enables or disables low-light boost (night mode).
enabled: 1 = on. -
setNativeDetector(
int textureId, String detector) → void -
Runs a NATIVE ML detector on the session's frames, emitting
CameraEventType.detection events with a JSON payload per hit.
detector: "barcode" | "face" | "" (off). Requires the host app to add the matching ML Kit dependency (see docs) — throws a descriptive error event if the detector class is not on the classpath. -
setSamplingRate(
int textureId, int samplingRate) → void -
Configures how many frames to skip before delivering to frameStream.
samplingRate: 1 = every frame, 2 = every 2nd frame, etc. -
setTargetOrientation(
int textureId, int degrees) → void - Sets the target output orientation in degrees (0 / 90 / 180 / 270).
-
setTorch(
int textureId, int enabled) → void -
Enables or disables the torch (continuous flashlight).
enabled: 1 = on. -
setTorchLevel(
int textureId, double level) → void - Sets the torch brightness in 0.0..1.0 (1.0 = max). Values > 0 imply torch on.
-
setVideoStabilization(
int textureId, int mode) → void - Sets the video stabilization mode. Pass a VideoStabilizationMode value.
-
setWhiteBalance(
int textureId, int temperature) → void - Sets the white-balance colour temperature in Kelvin. Pass 0 to restore automatic white balance.
-
setZoom(
int textureId, double zoom) → void - Sets the zoom level. Must be within CameraDevice.minZoom .. CameraDevice.maxZoom.
-
startPreview(
int textureId) → void - Resumes the camera preview after stopPreview.
-
startVideoRecording(
int textureId, String outputPath, RecordingOptions options) → Future< void> -
stopPreview(
int textureId) → void - Pauses the camera preview without closing the session.
-
stopVideoRecording(
int textureId) → Future< RecordingResult> -
takePhoto(
int textureId) → Future< PhotoResult> -
takePhotoWithOptions(
int textureId, PhotoOptions options) → Future< PhotoResult> -
Captures a photo using explicit
options(flash, quality, shutter sound). -
takeSnapshot(
int textureId) → Future< PhotoResult> - Captures the current preview frame as a fast JPEG snapshot (no full still-capture round-trip).
-
toString(
) → String -
A string representation of this object.
inherited
-
updateOverlay(
int textureId, Uint8List overlayData) → void -
Draws a persistent shape or text vector onto the camera overlay.
Renders directly on the GPU using the custom pipeline.
overlayDatais a serialized binary Buffer of draw commands.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → NitroCamera
-
final