pretty_qr_code
3.6.0A highly customizable Flutter widget that makes it easy to render QR codes.
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)
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:
PrettyQrRoundedSymbolshape is now deprecated in favor of thePrettyQrSquaresSymbol.
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
PrettyQrBrushgradient filling option #40. - Added
PrettyQrThemeextension #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
errorBuildertoPrettyQrView.dataconstructor.
3.1.0
- Optimize QR code repaints #10. Thanks to nxtSwitch (#28).
- Added the ability to save code to an image with
toImageandtoImageAsBytesmethods #14.
3.0.0
Note: This release has breaking changes.
- Added
PrettyQrDecorationTween. - Added more options for embedding images.
PrettyQrDecorationImagePosition.embeddedPrettyQrDecorationImagePosition.backgroundPrettyQrDecorationImagePosition.foreground
- Added core interfaces and refactor internal organization.
- Updated documentation and example to follow new naming conventions.
- BREAKING: Package now requires
qrpackage>=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.
- Upgraded Dart SDK constraints to
- DEPRECATED:
PrettyQrwidget is now deprecated in favor of thePrettyQrViewwidget. - Update example app.
- Added some new patterns:
- Rounded (
PrettyQrRoundedSymbol) - Smooth (
PrettyQrSmoothSymbol)
- Rounded (
- 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
qrpackage>=3.0.0. Thanks to joj3000 (#11).- Upgraded Dart SDK constraints to
>=2.13.0 <3.0.0.
- Upgraded Dart SDK constraints to
2.0.2
- Added automatic detection of the minimum acceptable version number when the
typeNumberoption is omitted. Thanks to SBNTT (#4).
2.0.1
- Added
qrpackage to exports. - Refactor internal organization.
2.0.0
Note: This release has breaking changes.
- BREAKING: Package now requires
qrpackage>=2.0.0. - BREAKING: Мigrate to null-safety:
- Upgraded Dart SDK constraints to
>=2.12.0 <3.0.0.
- Upgraded Dart SDK constraints to
1.0.2
- Fixed QR code rebuild when no data changes. Thanks to daniel-lucas-silva (#5).
1.0.1
- Removed unnecessary
printfromPrettyQrCodePainter.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.typeNumberproperty.
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_codepubspec.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
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.1 | On demand | Download | 0a03b0b8…0bbd86 |
| 0.0.2 | On demand | Download | e348335a…652485 |
| 0.0.3 | On demand | Download | 0fa05830…0a6a4d |
| 0.0.4 | On demand | Download | 27aa0017…ec54e8 |
| 0.0.5 | On demand | Download | d47d3b2f…97c58d |
| 0.0.6 | On demand | Download | 8c3a68af…6aadf2 |
| 0.0.7 | On demand | Download | 4ac1fe0b…9b3f70 |
| 0.0.8 | On demand | Download | 25032f19…5da548 |
| 1.0.0 | On demand | Download | f3910ee9…1072a2 |
| 1.0.1 | On demand | Download | bbd65176…ec8303 |
| 1.0.2 | On demand | Download | 80ca79c4…599645 |
| 2.0.0 | On demand | Download | effa5dad…f8ba1e |
| 2.0.1 | On demand | Download | 6ec31ff9…1254f7 |
| 2.0.2 | On demand | Download | 9ce7e61f…40e40a |
| 2.0.3 | On demand | Download | ea7ccb30…0be647 |
| 3.0.0 | On demand | Download | 799fa8d5…e526d6 |
| 3.1.0 | On demand | Download | 2163eb6e…b34a16 |
| 3.2.0 | On demand | Download | c84fe1dd…2fb6b8 |
| 3.2.1 | On demand | Download | 47a0fde3…4b807e |
| 3.3.0 | On demand | Download | cbdb4af2…3607d5 |
| 3.4.0 | On demand | Download | b078bd5d…a8db74 |
| 3.5.0 | On demand | Download | 2291db3f…609259 |
| 3.6.0 | Cached · Upstream SHA-256 matched | Download | 474f8a45…be7a8a |
Dependencies
flutter {
"sdk": "flutter"
}
meta "^1.7.0"
qr "^3.0.1"