Barcode.itf constructor

Barcode.itf(
  1. List barcodeData
)

ITF (Interleaved 2 of 5)

k >= 2 (even number) d = '0'–'9'

Implementation

Barcode.itf(List<dynamic> barcodeData) {
  final k = barcodeData.length;
  if (k < 2 || !k.isEven) {
    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.itf;
  _data = _convertData(barcodeData);
}