crc property
String
get
crc
Calculates the CRC value for the given QR code data using the Crc16Ibm3740 algorithm.
The CRC is computed only for the portion of the data matching the regular expression pattern
^.+63\d{2}
. If no match is found, an empty string is returned.
qrData is the input QR code data string that includes the information to validate.
Returns:
- A string representing the calculated CRC in uppercase hexadecimal format.
Implementation
String get crc {
final match = RegExp(r'^.+63\d{2}').firstMatch(qrData)?.group(0);
if (match != null) {
final crc = Crc16Ibm3740().convert(utf8.encode(match));
return crc.toRadixString(16).toUpperCase();
}
return '';
}