Pretty QR Code

Pub Likes on pub.dev Star on Github License: MIT

A highly customizable Flutter widget that make it easy to rendering QR code.

Features

  • Live Preview
  • Built on qr package.
  • Supports embedding images.
  • Support tween animation.
  • Support some options for images.
  • Export qr as image.

If you want to say thank you, star us on GitHub or like us on pub.dev

Usage

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 build method, or you may otherwise have undesired jank in UI thread.

See the example folder for more code samples of the various possibilities.

Save the symbol as an image

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 imageBytes = await qrImage.toImageAsBytes(
  size: 512,
  format: ImageByteFormat.png,
  decoration: const PrettyQrDecoration(),
);

Contributing

Contributions are welcomed!

Here is a curated list of how you can help:

  • Fix typos/grammar mistakes
  • Report parts of the documentation that are unclear
  • Report bugs and scenarios that are difficult to implement

TODO:

  • Quiet Zone
  • Gradient filling
  • Export as image
  • Error handling API
  • Gaps between modules
  • Background color for QR code
  • Timing Patterns and Alignment Patterns
  • Automatic image scale limitation (embedded mode)

Libraries

pretty_qr_code
Flutter widgets that makes it easy to render QR codes.