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,
]) {
Writer writer;
switch (format) {
case BarcodeFormat.ean8:
writer = EAN8Writer();
break;
case BarcodeFormat.upcE:
writer = UPCEWriter();
break;
case BarcodeFormat.ean13:
writer = EAN13Writer();
break;
case BarcodeFormat.upcA:
writer = UPCAWriter();
break;
case BarcodeFormat.qrCode:
writer = QRCodeWriter();
break;
case BarcodeFormat.code39:
writer = Code39Writer();
break;
case BarcodeFormat.code93:
writer = Code93Writer();
break;
case BarcodeFormat.code128:
writer = Code128Writer();
break;
case BarcodeFormat.itf:
writer = ITFWriter();
break;
case BarcodeFormat.pdf417:
writer = PDF417Writer();
break;
case BarcodeFormat.codabar:
writer = CodaBarWriter();
break;
case BarcodeFormat.dataMatrix:
writer = DataMatrixWriter();
break;
case BarcodeFormat.aztec:
writer = AztecWriter();
break;
default:
throw ArgumentError('No encoder available for format $format');
}
return writer.encode(contents, format, width, height, hints);
}