of method
The check character of data, without it: one digit for gs1 and
luhn, one Code 39 character for mod43.
Throws ArgumentError if data is empty or has a character the
check does not take (anything but digits for gs1 and luhn).
Implementation
String of(String data) {
if (data.isEmpty) {
throw ArgumentError.value(data, 'data', 'is empty');
}
final int? bad = _invalidAt(data);
if (bad != null) {
throw ArgumentError.value(
data,
'data',
"'${data[bad]}' at position ${bad + 1}: the $name check takes "
'${this == mod43 ? r'capital letters, digits, space and - . $ / + %' : 'digits'} only',
);
}
return switch (this) {
gs1 => String.fromCharCode(0x30 + _gs1(data)),
luhn => String.fromCharCode(0x30 + _luhn(data)),
mod43 => _code39[_mod43(data)],
};
}