Camera#

Defined in library scandit_datacapture_core

TorchState#

Added in version 6.7.0

Possible values for the torch state.

on#

Added in version 6.7.0

Value to indicate that the torch is turned on.

off#

Added in version 6.7.0

Value to indicate that the torch is turned off.

auto#

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.

Note

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.

Camera#
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.

desiredState#
FrameSourceState get desiredState

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.desiredState.

currentState#
Future<FrameSourceState> get currentState

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.currentState.

position#
CameraPosition get position

Added in version 6.7.0

The direction that the camera faces.

addListener(listener)#
void addListener(FrameSourceListener? listener)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.addListener().

removeListener(listener)#
void removeListener(FrameSourceListener? listener)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.removeListener().

defaultCamera#
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.

atPosition(cameraPosition)#
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 FrameSourceState.off and has the default CameraSettings.

Important

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.

switchToDesiredState(state)#
Future<void> switchToDesiredState(FrameSourceState state)

Added in version 6.7.0

Implemented from FrameSource. See FrameSource.switchToDesiredState().

applySettings(settings)#
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 FrameSourceState.off 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.

isTorchAvailable#
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.

desiredTorchState#
TorchState desiredTorchState

Added in version 6.7.0

The desired torch state for this camera. By default, the torch state is TorchState.off. 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.