Frame Source

Defined in library scandit_datacapture_core

FrameSourceState

Added in version 6.7.0

The different states a frame source can be in.

on

Added in version 6.7.0

The frame source is on and producing frames.

off

Added in version 6.7.0

The frame source is off and not producing frames.

starting

Added in version 6.7.0

The frame source is currently starting (moving from off to state on). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently starting.

stopping

Added in version 6.7.0

The frame source is currently stopping (moving from on to state off). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently stopping.

standby

Added in version 6.7.0

The frame source is in standby and not producing frames.

bootingUp

Added in version 6.7.0

The frame source is currently booting up (moving from off to state standby). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently booting up.

wakingUp

Added in version 6.7.0

The frame source is currently waking up (moving from standby to state on). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently waking up.

goingToSleep

Added in version 6.7.0

The frame source is currently going to sleep (moving from on to state standby). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently going to sleep.

shuttingDown

Added in version 6.7.0

The frame source is currently shutting down (moving from standby to state off). This value cannot be set directly but is returned by FrameSource.currentState to indicate that the frame source is currently shutting down.

FrameSource
abstract class FrameSource

Added in version 6.7.0

Interface for producers of frames. Typically this interface is used through Camera which gives access to the built-in camera on Flutter. For more sophisticated use cases this interface can be implemented by programmers to support other sources of frames, such as external cameras with proprietary APIs.

Note

The FrameSource interface is currently restricted to frame sources included in the Scandit Data Capture SDK and cannot be used to implement custom frame sources.

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

Added in version 6.7.0

Sets the desired state of the frame source

Possible values are FrameSourceState.on/FrameSourceState.off. The frame source’s state needs to be switched to FrameSourceState.on for it to produce frames.

It is not allowed to set the desired state to FrameSourceState.starting/FrameSourceState.stopping. These values are only used to report ongoing state transitions.

In case the desired state is equal to the current state, calling this method has no effect. Otherwise, a call to this method initiates a state transition from the current state to the desired state.

The state transition is asynchronous, meaning that it may not complete immediately for certain frame source implementations. When a state transition is ongoing, further changes to the desired state are delayed until the state transition completes. Only the last of the desired states will be processed; previous requested state transitions will be cancelled.

The completion handler is invoked when the state transition finishes either on a background or on the calling thread. True is passed to the completion handler in case the state transition is successful, false if it either was cancelled or the state transition failed.

desiredState
FrameSourceState get desiredState

Added in version 6.7.0

Readonly attribute for accessing the desired state. Possible states are FrameSourceState.on, FrameSourceState.off, FrameSourceState.standby.

currentState
Future<FrameSourceState> get currentState

Added in version 6.7.0

Readonly attribute for accessing the current state. Possible states are FrameSourceState.on, FrameSourceState.off, FrameSourceState.standby, FrameSourceState.starting, FrameSourceState.stopping, FrameSourceState.bootingUp, FrameSourceState.wakingUp, FrameSourceState.goingToSleep, FrameSourceState.shuttingDown.

The current state cannot be changed directly, but is modified by switchToDesiredState().

context
DataCaptureContext? context

Added in version 6.7.0

The context this frame source is attached to. When the frame source is currently not attached to a context, null is returned.

addListener(listener)
void addListener(FrameSourceListener listener)

Added in version 6.7.0

Adds the listener to this frame source.

In case the same listener is already observing this instance, calling this method will not add the listener again.

removeListener(listener)
void removeListener(FrameSourceListener listener)

Added in version 6.7.0

Removes a previously added listener from this frame source.

In case the listener is not currently observing this instance, calling this method has no effect.