yardexx / qr_stringify

String QR generator for Dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QR Stringify

style: very good analysis License: MIT

Small package to generate QR codes that can be used in terminal output.

πŸ’™ Powered by Very Good Tools πŸ’™

🚧 Public API of this package is NOT STABLE. 🚧

As version suggests, QR Stringify shouldn't be used in production! More about semantic versioning here.

Simple 🎈

Easy to use. Simply create QR builder and provide data. Additionally, you can adjust padding and correction levels.

Flexible πŸ’ƒ

You can extend QrDrawer class and make custom implementation for drawing QR code.

Usage πŸ› 

Adding dependency πŸ“¦

This package is currently not available on pub.dev.

To add qr_stringify to your pubspec.yaml file, use git dependency:

dependencies:
  qr_stringify:
    git:
      url: 'https://github.com/yardexx/qr_stringify.git'

Creating QR Code πŸ‘·β€β™‚οΈ

To generate code, create instance of QrBuilder and provide data which you want to encode into QR Code. When you are satisfied with your settings, call build() to return QR code in form of String.

import 'package:qr_stringify/qr_stringify.dart';

// Creating builder
final builder = QrBuilder(data: 'Hello World');

// Building QR code
final code = builder.build();

πŸ’‘ QrBuilder currently defaults to utf8 drawer, which means, that QR code is generated using this charset. ASCII support is planned.

Adding padding πŸ”³

If you wish to add more space around code (also called quiet zone), you can do so by adding padding.

final builder = QrBuilder(data: 'Hello World')
  ..padding = 1;

// QR code with padding
final code = builder.build();

Error correction level πŸ”§

QR code can be generated with different levels of error corrections levels. These determine how much damage can QR code sustain before being unreadable.

Higher level means higher percentage of code can be damaged. In qr_stringify, these value are represented as ErrorCorrectionLevel with respective values:

  • ErrorCorrectionLevel.L - up to 7% damage
  • ErrorCorrectionLevel.M - up to 15% damage
  • ErrorCorrectionLevel.Q - up to 25% damage
  • ErrorCorrectionLevel.H - up to 30% damage

QrBuilder default value is ErrorCorrectionLevel.L. You can choose other values by passing them in builder.

final builder = QrBuilder(data: 'Hello World')
  ..correctionLevel = ErrorCorrectionLevel.L;

❗ Be aware that higher level of correction will result in bigger code.

More about error correction in QR codes here.

A note about line spacing (line height) πŸ“

While qr_stringify is designed to be used in terminal, not all terminals will display code correctly. Some terminals which have bigger line spacing (> 1.0) will display a little bit of space between each line of code.

Ideally, QR code should look like this: Ideal QR code

In most cases, you will end up with code that looks like this: Common QR code

But sometimes, you will get totally broken code: Broken QR code

Most of the time, first situation will occur which makes code still readable just fine. Second case can be fixed by adjusting line spacing of terminal.

❗ Be aware of line spacing (line height) of terminal.

Planned features πŸ—Ί

  • ASCII support
  • Borders
  • Colors (ANSI)
  • Title texts with links

Contribution 🀝

For issues, bugs, or feature proposals feel free to open issue or create PR.

About

String QR generator for Dart.

License:MIT License


Languages

Language:Dart 100.0%