Reputation: 407
I try to print out qr code to thermal printer by using flutter_bluetooth_serial.
I generate the qr code by using following guide https://medium.com/flutter-community/building-flutter-qr-code-generator-scanner-and-sharing-app-703e73b228d3
I manage to convert the image into Uint8List and send to the printer.
Future<Uint8List> _getQrByte() async {
RenderRepaintBoundary boundary =
globalKey.currentContext.findRenderObject();
var image = await boundary.toImage();
var byteData = await image.toByteData();
return byteData.buffer.asUint8List();
}
and I call function in flutter_bluetooth_serial
await _bluetooth.writeBytes(bytes);
I expect to print a perfect qr code, but the printout is random char and very long.
In android, I manage to print out by sending byte array from bitmap class to the printer
Upvotes: 1
Views: 3870
Reputation: 35
You can use this:
final profile = await CapabilityProfile.load(name: 'XP-N160I');
final generator = Generator(PaperSize.mm80, profile);
bytes += generator.qrcode(
'https://github.com/BrunoSantosCosta',
size: const QRSize(30),
);
Upvotes: 0
Reputation: 451
Have you tried esc_pos_bluetooth for a Bluetooth printer (or esc_pos_printer for a WiFi/network printer)? Both packages can print QR codes
Upvotes: 1