pretty_qr_code

3.6.0

A highly customizable Flutter widget that makes it easy to render QR codes.

Download archive

Readme

Pretty QR Code

A highly customizable Flutter widget that makes it easy to render QR codes. Built on top of the qr package.

Features

  • Live Preview
  • Shapes - The widget provides functionality for rendering various built-in shapes, namely smooth, squares and dots, or you can even create your patterns using the package API.
  • Themes - Allows you easily switch between themes using the material theme extension.
  • Branding - Configure the display of the embedded image and adjust its style to best fit your needs.
  • Exporting - Save the QR сode as an image for sharing, embedding, or anything else.
  • Customization - Customize the appearance by setting the shape color or filling with a gradient.

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'),
    ),
    quietZone: PrettyQrQuietZone.standart,
  ),
)

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.

Combine several styles

To combine multiple styles in a single QR code, you can use PrettyQrCustomShape, as shown in the example below:

PrettyQrView.data(
  data: 'lorem ipsum dolor sit amet',
  decoration: const PrettyQrDecoration(
    shape: PrettyQrShape.custom(
      PrettyQrSquaresSymbol(),
      finderPattern: PrettyQrSmoothSymbol(),
      alignmentPatterns: PrettyQrDotsSymbol(),
    ),
  ),
)

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

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

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

Planned for future release(s)

  • Quiet Zone
  • Gradient filling
  • Export as image
  • Error handling API
  • Background color for QR code
  • Timing Patterns and Alignment Patterns
  • Support custom clippers for embedded images (#38)
  • Export as vector image (#42)
Changelog

3.6.0

  • Add configurable bounds for QR code shapes.
  • Optimized QR code rendering for the simple shape variants.
  • Add support custom clippers for embedded images #38.

3.5.0

  • Added new patterns: dots and squares.
  • Added support custom styles per QR components #51.
  • DEPRECATED: PrettyQrRoundedSymbol shape is now deprecated in favor of the PrettyQrSquaresSymbol.

3.4.0

  • Added quiet zone support #44.
  • Updated web renderer detection #55.
  • Added support compilation to WASM. Thanks to s-philippov (#52).

3.3.0

  • Added PrettyQrBrush gradient filling option #40.
  • Added PrettyQrTheme extension #37.
  • Added assert when platform does not support export.

3.2.1

  • Fixed bug when errorBuilder was working incorrectly when data was changed.

3.2.0

  • Added errorBuilder to PrettyQrView.data constructor.

3.1.0

  • Optimize QR code repaints #10. Thanks to nxtSwitch (#28).
  • Added the ability to save code to an image with toImage and toImageAsBytes methods #14.

3.0.0

Note: This release has breaking changes.

  • Added PrettyQrDecorationTween.
  • Added more options for embedding images.
    • PrettyQrDecorationImagePosition.embedded
    • PrettyQrDecorationImagePosition.background
    • PrettyQrDecorationImagePosition.foreground
  • Added core interfaces and refactor internal organization.
  • Updated documentation and example to follow new naming conventions.
  • BREAKING: Package now requires qr package >=3.0.1.
    • Upgraded Dart SDK constraints to >=2.17.0 <4.0.0.
    • Upgraded Flutter SDK constraints to >=3.0.0 <4.0.0.
  • DEPRECATED: PrettyQr widget is now deprecated in favor of the PrettyQrView widget.
  • Update example app.
  • Added some new patterns:
    • Rounded (PrettyQrRoundedSymbol)
    • Smooth (PrettyQrSmoothSymbol)
  • Fixed stripes between qr code modules, #3.
  • Fixed embedded image loading: #15.

2.0.3

Note: This release has breaking changes.

  • BREAKING: Package now requires qr package >=3.0.0. Thanks to joj3000 (#11).
    • Upgraded Dart SDK constraints to >=2.13.0 <3.0.0.

2.0.2

  • Added automatic detection of the minimum acceptable version number when the typeNumber option is omitted. Thanks to SBNTT (#4).

2.0.1

  • Added qr package to exports.
  • Refactor internal organization.

2.0.0

Note: This release has breaking changes.

  • BREAKING: Package now requires qr package >=2.0.0.
  • BREAKING: Мigrate to null-safety:
    • Upgraded Dart SDK constraints to >=2.12.0 <3.0.0.

1.0.2

1.0.1

  • Removed unnecessary print from PrettyQrCodePainter.paint.

1.0.0

  • Fixed QR code displaying without image.

0.0.8

  • Added example project.

0.0.7

  • Added support for embedded images.
  • Updated screenshots and usage example.

0.0.6

  • Fixed inner corners color.

0.0.5

  • Fixed transparent background.

0.0.4

  • Updated screenshots.
  • Added rounding to the inner corners.
  • Added a PrettyQr.typeNumber property.

0.0.3

  • Updated package description.

0.0.2

  • Added screenshots and usage example.

0.0.1

  • Initial version of the library.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add pretty_qr_code
pubspec.yaml
name: pretty_qr_code
description: A highly customizable Flutter widget that makes it easy to render QR codes.

version: 3.6.0
homepage: https://github.com/promops/flutter_pretty_qr

topics:
  - qr
  - pretty-qr
  - pretty-widgets

screenshots:
  - description: A smoothed QR code.
    path: resources/qr-code-blue.png

environment:
  sdk: '>=2.17.0 <4.0.0'
  flutter: ">=3.0.0"

dependencies:
  flutter:
    sdk: flutter

  qr: ^3.0.1
  meta: ^1.7.0

dev_dependencies:
  # tests
  flutter_test:
    sdk: flutter

  # lints
  flutter_lints: ^2.0.1
  dart_code_metrics_presets: ^2.24.0

Version history

VersionPublishedArchiveSHA-256
0.0.1On demandDownload0a03b0b8…0bbd86
0.0.2On demandDownloade348335a…652485
0.0.3On demandDownload0fa05830…0a6a4d
0.0.4On demandDownload27aa0017…ec54e8
0.0.5On demandDownloadd47d3b2f…97c58d
0.0.6On demandDownload8c3a68af…6aadf2
0.0.7On demandDownload4ac1fe0b…9b3f70
0.0.8On demandDownload25032f19…5da548
1.0.0On demandDownloadf3910ee9…1072a2
1.0.1On demandDownloadbbd65176…ec8303
1.0.2On demandDownload80ca79c4…599645
2.0.0On demandDownloadeffa5dad…f8ba1e
2.0.1On demandDownload6ec31ff9…1254f7
2.0.2On demandDownload9ce7e61f…40e40a
2.0.3On demandDownloadea7ccb30…0be647
3.0.0On demandDownload799fa8d5…e526d6
3.1.0On demandDownload2163eb6e…b34a16
3.2.0On demandDownloadc84fe1dd…2fb6b8
3.2.1On demandDownload47a0fde3…4b807e
3.3.0On demandDownloadcbdb4af2…3607d5
3.4.0On demandDownloadb078bd5d…a8db74
3.5.0On demandDownload2291db3f…609259
3.6.0Cached · Upstream SHA-256 matchedDownload474f8a45…be7a8a

Dependencies

flutter { "sdk": "flutter" }

meta "^1.7.0"

qr "^3.0.1"