A QR code generation package for Dart.
Features
- Supports QR code versions 1 - 40
- Error correction / redundancy
- ECI (Extended Channel Interpretation) support
Demo
A rich, HTML demo can be found at: qr.kevmoo.com.
Getting started
To start, import the dependency in your code:
import 'package:qr/qr.dart';
To build your QR code data you should do so as such:
final qrCode = QrCode(
payload: QrPayload.fromString('Hello, world in QR form!'),
errorCorrectLevel: QrErrorCorrectLevel.low,
);
final qrImage = QrImage(qrCode);
To enable Extended Channel Interpretation (ECI) mode or build multi-part data, you can use QrPayload:
final payload = QrPayload()
..addECI(QrEciValue.utf8)
..addString('Hello, world in QR form!');
final qrCode = QrCode(
payload: payload,
errorCorrectLevel: QrErrorCorrectLevel.low,
);
Now you can use your qrImage instance to render a graphical representation of
the QR code. A basic implementation would be as such:
for (var x = 0; x < qrImage.moduleCount; x++) {
for (var y = 0; y < qrImage.moduleCount; y++) {
if (qrImage.isDark(y, x)) {
// render a dark square on the canvas
}
}
}
See the example directory for further details.
Packages that use package:qr
- pretty_qr_code - A Flutter Widget to render QR codes
- qr_image_exporter - A library to export QR codes as PNG image data.
