convert method
Implementation
@override
Barcode2DMatrix convert(Uint8List data) {
final QrErrorCorrectLevel errorLevel = switch (errorCorrectLevel) {
BarcodeQRCorrectionLevel.low => QrErrorCorrectLevel.low,
BarcodeQRCorrectionLevel.medium => QrErrorCorrectLevel.medium,
BarcodeQRCorrectionLevel.quartile => QrErrorCorrectLevel.quartile,
BarcodeQRCorrectionLevel.high => QrErrorCorrectLevel.high,
};
QrPayload payload;
try {
payload = QrPayload.fromString(utf8.decode(data));
} catch (_) {
payload = QrPayload.fromTypedData(data);
}
final QrCode qrCode = QrCode(
payload: payload,
errorCorrectLevel: errorLevel,
minTypeNumber: typeNumber ?? 1,
);
final QrImage qrImage = QrImage(qrCode);
return Barcode2DMatrix.fromXY(
qrCode.moduleCount,
qrCode.moduleCount,
1,
qrImage.isDark,
);
}