MultiFormatOneDReader constructor

MultiFormatOneDReader(
  1. Map<DecodeHintType, Object>? hints
)

Implementation

MultiFormatOneDReader(Map<DecodeHintType, Object>? hints) {
  // @SuppressWarnings("unchecked")
  final possibleFormats =
      hints?[DecodeHintType.POSSIBLE_FORMATS] as List<BarcodeFormat>?;
  final useCode39CheckDigit = hints != null &&
      hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] != null;
  final readers = <OneDReader>[];
  if (possibleFormats != null) {
    if (possibleFormats.contains(BarcodeFormat.EAN_13) ||
        possibleFormats.contains(BarcodeFormat.UPC_A) ||
        possibleFormats.contains(BarcodeFormat.EAN_8) ||
        possibleFormats.contains(BarcodeFormat.UPC_E)) {
      readers.add(MultiFormatUPCEANReader(hints));
    }
    if (possibleFormats.contains(BarcodeFormat.CODE_39)) {
      readers.add(Code39Reader(useCode39CheckDigit));
    }
    if (possibleFormats.contains(BarcodeFormat.CODE_93)) {
      readers.add(Code93Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.CODE_128)) {
      readers.add(Code128Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.ITF)) {
      readers.add(ITFReader());
    }
    if (possibleFormats.contains(BarcodeFormat.CODABAR)) {
      readers.add(CodaBarReader());
    }
    if (possibleFormats.contains(BarcodeFormat.RSS_14)) {
      readers.add(RSS14Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.RSS_EXPANDED)) {
      readers.add(RSSExpandedReader());
    }
  }
  if (readers.isEmpty) {
    readers.add(MultiFormatUPCEANReader(hints));
    readers.add(Code39Reader());
    readers.add(CodaBarReader());
    readers.add(Code93Reader());
    readers.add(Code128Reader());
    readers.add(ITFReader());
    readers.add(RSS14Reader());
    readers.add(RSSExpandedReader());
  }
  _readers = readers; //.toList();
}