Browse Source

fixed multiple code scan issue from image path

pull/98/head
Khoren Markosyan 2 years ago
parent
commit
e0eef28092
  1. 19
      lib/src/ui/reader_widget.dart

19
lib/src/ui/reader_widget.dart

@ -458,15 +458,25 @@ class _ReaderWidgetState extends State<ReaderWidget>
final XFile? file = final XFile? file =
await ImagePicker().pickImage(source: ImageSource.gallery); await ImagePicker().pickImage(source: ImageSource.gallery);
if (file != null) { if (file != null) {
final Code result = await zx.readBarcodeImagePath( final DecodeParams params = DecodeParams(
file,
params: DecodeParams(
format: widget.codeFormat, format: widget.codeFormat,
tryHarder: widget.tryHarder, tryHarder: widget.tryHarder,
tryInverted: widget.tryInverted, tryInverted: widget.tryInverted,
isMultiScan: widget.isMultiScan, isMultiScan: widget.isMultiScan,
),
); );
if (widget.isMultiScan) {
final Codes result =
await zx.readBarcodesImagePath(file, params: params);
if (result.codes.isNotEmpty) {
results = result;
widget.onMultiScan?.call(result);
setState(() {});
} else {
results = Codes();
widget.onMultiScanFailure?.call(result);
}
} else {
final Code result = await zx.readBarcodeImagePath(file, params: params);
if (result.isValid) { if (result.isValid) {
widget.onScan?.call(result); widget.onScan?.call(result);
} else { } else {
@ -474,6 +484,7 @@ class _ReaderWidgetState extends State<ReaderWidget>
} }
} }
} }
}
void _onCameraButtonTapped() { void _onCameraButtonTapped() {
if (cameras.isEmpty || controller == null) { if (cameras.isEmpty || controller == null) {

Loading…
Cancel
Save