Barcode.codabar constructor

Barcode.codabar(
  1. List barcodeData
)

CODABAR (NW-7)

k >= 2 d: '0'–'9', A–D, a–d, $, +, −, ., /, : However, d0 = A–D, dk = A–D (65-68) d0 = a-d, dk = a-d (97-100)

Implementation

Barcode.codabar(List<dynamic> barcodeData) {
  final k = barcodeData.length;
  if (k < 2) {
    throw Exception('Barcode: Wrong data range');
  }

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

  if ((_charcode(barcodeData[0]) >= 65 && _charcode(barcodeData[0]) <= 68) &&
      !(_charcode(barcodeData[k - 1]) >= 65 &&
          _charcode(barcodeData[k - 1]) <= 68)) {
    throw Exception('Barcode: Wrong data range');
  }

  if ((_charcode(barcodeData[0]) >= 97 && _charcode(barcodeData[0]) <= 100) &&
      !(_charcode(barcodeData[k - 1]) >= 97 &&
          _charcode(barcodeData[k - 1]) <= 100)) {
    throw Exception('Barcode: Wrong data range');
  }

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