getScanData method

ScanData getScanData(
  1. String barcode
)

multipurpose scanner processing. Can throw

Implementation

ScanData getScanData(String barcode) {
  ScanData? data;
  String? errorMessage;

  try {
    // Handle GS1 case
    data = _getDataFromGs1Code(barcode);
  } on Exception catch (_) {
    // Handle non-GS1 QR/2D code
    // 1. TM
    data = _getMaterialScanDataFromQRCode(barcode);
    // 2. Order numbers
    data ??= _getOrderNumbersFromQr(barcode);
    // Handle 1D order number cases:
    data ??= _getOrderNumbersFromBarcode(barcode);
    // Handle plain int numbers.
    data ??= _getIntFromCode(barcode);
  }

  data ??= ScanData(uncategorizedString: barcode);
  return data.copyWith(errorMessage: errorMessage);
}