Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1010 B

part of 'zxing.dart';
IsolateUtils? isolateUtils;
/// Starts reading barcode from the camera
Future<void> startCameraProcessing() async {
isolateUtils = IsolateUtils();
await isolateUtils?.startReadingBarcode();
}
/// Stops reading barcode from the camera
void stopCameraProcessing() => isolateUtils?.stopReadingBarcode();
Future<CodeResult> processCameraImage(
CameraImage image, {
int format = Format.Any,
double cropPercent = 0.5,
bool tryHarder = false,
bool tryInverted = false,
}) async {
final IsolateData isolateData =
IsolateData(image, format, cropPercent, tryHarder, tryInverted);
final CodeResult result = await _inference(isolateData);
return result;
}
/// Runs inference in another isolate
Future<CodeResult> _inference(IsolateData isolateData) async {
final ReceivePort responsePort = ReceivePort();
isolateUtils?.sendPort
?.send(isolateData..responsePort = responsePort.sendPort);
final dynamic results = await responsePort.first;
return results;
}