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.

31 lines
906 B

part of 'zxing.dart';
IsolateUtils? isolateUtils;
/// Starts reading barcode from the camera
Future<void> zxingStartCameraProcessing() async {
isolateUtils = IsolateUtils();
await isolateUtils?.startReadingBarcode();
}
/// Stops reading barcode from the camera
void zxingStopCameraProcessing() => isolateUtils?.stopReadingBarcode();
Future<dynamic> zxingProcessCameraImage(
CameraImage image, {
DecodeParams? params,
}) async {
final IsolateData isolateData = IsolateData(image, params ?? DecodeParams());
final dynamic result = await _inference(isolateData);
return result;
}
/// Runs inference in another isolate
Future<dynamic> _inference(IsolateData isolateData) async {
final ReceivePort responsePort = ReceivePort();
isolateUtils?.sendPort
?.send(isolateData..responsePort = responsePort.sendPort);
final dynamic results = await responsePort.first;
return results;
}