Barcode.upcA constructor

Barcode.upcA(
  1. List barcodeData
)

UPC-A

k = 11, 12 d = '0' – '9'

Implementation

Barcode.upcA(List<dynamic> barcodeData) {
  final k = barcodeData.length;
  if (![11, 12].contains(k)) {
    throw Exception('Barcode: Wrong data range');
  }

  final numeric = RegExp(r'^[0-9]$');
  final bool isDataValid =
      barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
  if (!isDataValid) {
    throw Exception('Barcode: Data is not valid');
  }

  _type = BarcodeType.upcA;
  _data = _convertData(barcodeData);
}