decodeMultiple method

  1. @override
List<Result> decodeMultiple(
  1. BinaryBitmap image, [
  2. Map<DecodeHintType, Object>? hints
])
override

Implementation

@override
List<Result> decodeMultiple(
  BinaryBitmap image, [
  Map<DecodeHintType, Object>? hints,
]) {
  List<Result> results = [];
  final detectorResults = MultiDetector(image.blackMatrix).detectMulti(hints);
  for (DetectorResult detectorResult in detectorResults) {
    try {
      final decoderResult = decoder.decodeMatrix(detectorResult.bits, hints);
      final points = detectorResult.points;
      // If the code was mirrored: swap the bottom-left and the top-right points.
      if (decoderResult.other is QRCodeDecoderMetaData) {
        (decoderResult.other as QRCodeDecoderMetaData)
            .applyMirroredCorrection(points);
      }
      final result = Result(
        decoderResult.text,
        decoderResult.rawBytes,
        points,
        BarcodeFormat.QR_CODE,
      );
      final byteSegments = decoderResult.byteSegments;
      if (byteSegments != null) {
        result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
      }
      final ecLevel = decoderResult.ecLevel;
      if (ecLevel != null) {
        result.putMetadata(
          ResultMetadataType.ERROR_CORRECTION_LEVEL,
          ecLevel,
        );
      }
      if (decoderResult.hasStructuredAppend) {
        result.putMetadata(
          ResultMetadataType.STRUCTURED_APPEND_SEQUENCE,
          decoderResult.structuredAppendSequenceNumber,
        );
        result.putMetadata(
          ResultMetadataType.STRUCTURED_APPEND_PARITY,
          decoderResult.structuredAppendParity,
        );
      }
      results.add(result);
    } on ReaderException catch (_) {
      // ignore and continue
    }
  }
  if (results.isEmpty) {
    return _emptyResultArray;
  } else {
    results = processStructuredAppend(results);
    return results.toList();
  }
}