verifyBytes method

  1. @override
void verifyBytes(
  1. Uint8List data
)
override

Check if the Barcode is valid. Throws BarcodeException with a proper message in case of error

Implementation

@override
void verifyBytes(Uint8List data) {
  var text = utf8.decoder.convert(data);

  if (text.length <= 8) {
    // Try to convert UPC-E to UPC-A
    text = upceToUpca(text);
  }

  if (text.length < 11) {
    throw BarcodeException(
        'Unable to encode "$text", minimum length is 11 for $name Barcode');
  }

  final upca = checkLength(text, maxLength);
  if (!fallback) {
    upcaToUpce(upca);
  }

  super.verifyBytes(utf8.encoder.convert(text));
}