Pretty QR code with round edges.
A highly customizable Flutter widget that makes it easy to render QR codes. Built on top of the qr package.
If you want to say thank you, star us on GitHub or like us on pub.dev.
First, follow the package installation instructions and add a PrettyQrView
widget to your app:
PrettyQrView.data(
data: 'lorem ipsum dolor sit amet',
decoration: const PrettyQrDecoration(
image: PrettyQrDecorationImage(
image: AssetImage('images/flutter.png'),
),
),
)
If you want to pass non-string data or want to specify a QR version, consider using the default PrettyQrView
constructor:
@protected
late QrImage qrImage;
@override
void initState() {
super.initState();
final qrCode = QrCode(
8,
QrErrorCorrectLevel.H,
)..addData('lorem ipsum dolor sit amet');
qrImage = QrImage(qrCode);
}
@override
Widget build(BuildContext context) {
return PrettyQrView(
qrImage: qrImage,
decoration: const PrettyQrDecoration(),
);
}
Note: Do not create QrImage
inside the build
method; otherwise, you may have an undesired jank in the UI thread.
You can save the QR code as an image using the toImage or toImageAsBytes extension methods that apply to QrImage
. Optionally, the configuration
parameter may be used to set additional saving options, such as pixel ratio or text direction.
final qrCode = QrCode.fromData(
data: 'lorem ipsum dolor sit amet',
errorCorrectLevel: QrErrorCorrectLevel.H,
);
final qrImage = QrImage(qrCode);
final qrImageBytes = await qrImage.toImageAsBytes(
size: 512,
format: ImageByteFormat.png,
decoration: const PrettyQrDecoration(),
);
See the example
folder for more code samples of the various possibilities.
Contributions are welcomed!
Here is a curated list of how you can help: