Defined in library scandit_datacapture_core


Added in version 6.7.0

Possible values for the torch state.


Added in version 6.7.0

Value to indicate that the torch is turned on.


Added in version 6.7.0

Value to indicate that the torch is turned off.


Added in version 6.7.0

Value to indicate that the torch is managed automatically. The torch is turned on or off based on the available illumination.


This is an experimental feature. This functionality may or may not work for your use case or may be removed in future version of this software.

abstract class TorchListener

Added in version 6.12.0

Interface definition for a callback to be invoked when the TorchState of a Camera changes.

void didChangeTorchToState(TorchState state)

Added in version 6.12.0

Called when TorchState changed.

class Camera : FrameSource

Added in version 6.7.0

Gives access to the built-in camera on Flutter. It implements the FrameSource interface, and, as such can be set as the frame source for the DataCaptureContext.

Instances of this class are created through one of the factory methods defaultCamera(), or atPosition().

The camera is started by changing the desired state to FrameSourceState.on.

By default, the resolution of captured frames as well as auto-focus and exposure settings are chosen such that they work best for a variety of use cases. To fine-tune recognition, the camera settings can be changed through applying new camera settings.

FrameSourceState get desiredState

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.desiredState.

Future<FrameSourceState> get currentState

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.currentState.

CameraPosition get position

Added in version 6.7.0

The direction that the camera faces.

void addListener(FrameSourceListener? listener)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.addListener().

void removeListener(FrameSourceListener? listener)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.removeListener().

static Camera? get defaultCamera

Added in version 6.7.0

Gets the default camera of the device. This method is identical to calling atPosition() repeatedly, first with CameraPosition.worldFacing, then with CameraPosition.userFacing followed by CameraPosition.unspecified, stopping after the first of these calls returns a non-null instance.

See atPosition() for a more detailed description of the method behavior.

static Camera? atPosition(CameraPosition cameraPosition)

Added in version 6.7.0

Retrieves the camera instance of the first camera at the provided position. In case the system does not have a camera at the provided position, null is returned.

When this method is called multiple times with the same argument, the same Camera instance is returned. The FrameSource.currentState of the camera as well as the settings depend on previous invocations. For example, if the camera is currently in use and is active, the camera’s FrameSource.currentState will be FrameSourceState.on. The only guarantee about the state and settings is that when instance is initially created, the FrameSource.currentState is and has the default CameraSettings.


In case parts of your app use custom camera settings and others use the default settings, make sure to reset the camera to use the default settings when you need them by passing the default camera settings to applySettings() to ensure that you don’t have any other settings when you’d expect the defaults to be active.

The camera object is returned if present, regardless whether the application has permissions to use it or not.

Future<void> switchToDesiredState(FrameSourceState state)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.switchToDesiredState().

Future<void> applySettings(CameraSettings settings)

Added in version 6.7.0

Applies the camera settings to the camera. The task will complete when the settings have been applied and the camera has switched to use the new settings. If the camera is currently in state, the task will complete immediately. If, on the other hand, the camera is currently in FrameSourceState.on state, the settings will be modified on the fly.

Future<bool> get isTorchAvailable

Added in version 6.7.0

Whether the torch is available for the given camera.

Android only: When the camera is off, this method always returns false. When the camera is on, it returns true for cameras that support the torch, false otherwise.

TorchState desiredTorchState

Added in version 6.7.0

The desired torch state for this camera. By default, the torch state is When setting the desired torch state to TorchState.on, the torch will be on as long as the camera is running (the camera’s state is FrameSourceState.on) and off otherwise.

void addTorchListener(TorchListener listener)

Added in version 6.12.0

Add a listener that will be called when TorchState of the camera changes.

void removeTorchListener(TorchListener listener)

Added in version 6.12.0

Remove a listener for TorchState changes.