encode method
BitMatrix
encode(
- String contents,
- BarcodeFormat format,
- int width,
- int height, [
- EncodeHint? hints,
override
@param contents The contents to encode in the barcode @param format The barcode format to generate @param width The preferred width in pixels @param height The preferred height in pixels @param hints Additional parameters to supply to the encoder @return BitMatrix representing encoded barcode image @throws WriterException if contents cannot be encoded legally in a format
Implementation
@override
BitMatrix encode(
String contents,
BarcodeFormat format,
int width,
int height, [
EncodeHint? hints,
]) {
if (format != BarcodeFormat.upcA) {
throw ArgumentError('Can only encode UPC-A, but got $format');
}
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
return _subWriter.encode(
'0$contents',
BarcodeFormat.ean13,
width,
height,
hints,
);
}