Barcode.ean13 constructor

Barcode.ean13(
  1. List barcodeData
)

JAN13 (EAN13)

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

Implementation

Barcode.ean13(List<dynamic> barcodeData) {
  final k = barcodeData.length;
  if (![12, 13].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.ean13;
  _data = _convertData(barcodeData);
}