Giter VIP home page Giter VIP logo

qr_stringify's Introduction

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.

qr_stringify's People

Contributors

yardexx avatar dependabot[bot] avatar

Watchers

 avatar

qr_stringify's Issues

feat: Color support

Description

As a developer I want to generate colorful qr code so that I can provide nicer experience.

feat: Link anchors

Description

As a developer, I want to provide clickable text below QR code to help people reach my (encoded) content more conveniently.

feat: Add borders

Description

As a developer I want to be able to add border around my code, so that I can provide more concise image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.