startScanning method
Implementation
Future<void> startScanning({UCodeScanOptions? options, UScanEngine? engine}) async {
final int? id = _sessionId;
if (id == null || value.isScanning) return;
if (options != null || engine != null) {
_config = _config.copyWith(scanOptions: options, scanEngine: engine);
}
final bool usePlatform = _config.scanEngine != UScanEngine.dart && value.capabilities.platformScanning;
if (usePlatform) {
await _set("startScanning", <String, Object?>{"options": _config.scanOptions.toMap()});
} else {
_frames ??= UCameraChannel.frames(id).listen(_onFrame, onError: _onStreamError);
await _set("startImageStream", <String, Object?>{
"format": _config.frameFormat.name,
"maxFps": _config.frameMaxFps,
"downscale": _config.frameDownscale,
});
}
_recentCodes.clear();
_emit(value.copyWith(isScanning: true));
}