printQrCode method
void
printQrCode(
- String data, {
- QrCodeModel model = QrCodeModel.model1,
- int size = 6,
- QrErrorLevel errorLevel = QrErrorLevel.low,
- PrintAlignment? alignment,
Print QrCode containing data and specify it's model, size and errorLevel.
Most thermal printer only have two models which are QrCodeModel.model1 and QrCodeModel.model2, but certain printer model also have QrCodeModel.micro model. Check your printer manufacturer documentation to know whether your printer can also print QrCodeModel.micro model.
QrCode size can be ranging from 1 to 16. A certain printer model can only be ranging from 3 to 16.
Check your printer manufacturer documentation to know what size range can it print.
QrErrorLevel specify the QrCode error correction level.
| Error Level | Recovery Capacity Approx. (%) |
|---|---|
| QrErrorLevel.low | 7 |
| QrErrorLevel.medium | 15 |
| QrErrorLevel.quartile | 25 |
| QrErrorLevel.high | 30 |
Throw AssertionError if:
sizeis not in range between 1 to 16.datain utf8.encoded format is empty.datain utf8.encoded format contains more than 7089 elements.
References:
Implementation
void printQrCode(
String data, {
QrCodeModel model = QrCodeModel.model1,
int size = 6,
QrErrorLevel errorLevel = QrErrorLevel.low,
PrintAlignment? alignment,
}) {
_commands.addAll([
if (alignment != null) SetPrintAlignment(alignment: alignment),
PrintQrCode.setQrModel(model: model),
PrintQrCode.setQrModuleSize(n: size),
PrintQrCode.setErrorLevel(errorLevel: errorLevel),
PrintQrCode.storeQrString(qrData: data),
const PrintQrCode.printQrCode(),
]);
}