MultiFormatUPCEANReader constructor

MultiFormatUPCEANReader(
  1. DecodeHint? hints
)

Implementation

MultiFormatUPCEANReader(DecodeHint? hints) {
  // @SuppressWarnings("unchecked")
  final possibleFormats = hints?.possibleFormats;
  final readers = <UPCEANReader>[];
  if (possibleFormats != null) {
    if (possibleFormats.contains(BarcodeFormat.ean13)) {
      readers.add(EAN13Reader());
    } else if (possibleFormats.contains(BarcodeFormat.upcA)) {
      readers.add(UPCAReader());
    }
    if (possibleFormats.contains(BarcodeFormat.ean8)) {
      readers.add(EAN8Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.upcE)) {
      readers.add(UPCEReader());
    }
  }
  if (readers.isEmpty) {
    readers.add(EAN13Reader());
    // UPC-A is covered by EAN-13
    readers.add(EAN8Reader());
    readers.add(UPCEReader());
  }
  _readers = readers.toList();
}