barcode 1.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

barcode #

Barcode generation library for Dart that can generate generic drawing operations for any backend.

  • If you are looking to print barcodes, use pub:pdf.
  • If you want to display barcodes in a Flutter application, use pub:barcode_widget.
  • To generate SVG barcodes see the example tab.

They all use this library to generate the drawing operations.


Buy Me A Coffee

This library is the base to create flutter widgets or pdf barcodes. It depends only on dart with no platform-dependent implementation.

Only two basic drawing primitives are required:

  • Filled rectangle to draw the bars
  • Text drawing to display the code in full-text

See the example for how to use it.

Code 39 #

CODE 39

Code 93 #

CODE 93

Code 128 A #

CODE 128 A

Code 128 B #

CODE 128 B

Code 128 C #

CODE 128 C

GS1-128 #

GS1 128

ITF 14 #

ITF 14

EAN 13 #

EAN 13

EAN 8 #

EAN 8

EAN 2 #

EAN 2

EAN 5 #

EAN 5

ISBN #

ISBN

UPC-A #

UPC A

UPC-E #

UPC E

Changelog #

1.5.0 #

  • Reorganize the library
  • Add EAN 2
  • Add EAN 5
  • Add GS1-128 support
  • Add ITF-14

1.4.0 #

  • Implement proper EAN-13 rendering
  • Implement proper UPC-A rendering
  • Implement proper UPC-E rendering
  • Implement proper EAN-8 rendering
  • Implement proper ISBN rendering

1.3.0 #

  • Add text align property
  • Add a SVG drawing function

1.2.0 #

  • Add a method to check Barcode validity
  • Add CODE 128 A
  • Add CODE 128 C
  • Add misc functions to Barcode

1.1.2 #

  • Update README

1.1.1 #

  • Fix URLs

1.1.0 #

  • Add EAN13
  • Add EAN8
  • Add ISBN
  • Add UPC-A
  • Add UPC-E
  • Fix Code 93

1.0.0 #

Breaking change: different API

  • Supports text output
  • Add CODE 93
  • Add CODE 128 B
  • Add documentation

0.1.0 #

  • Initial release, only CODE 39 support for now

example/main.dart

// ignore_for_file: always_specify_types

import 'dart:io';

import 'package:barcode/barcode.dart';

void buildBarcode(Barcode bc, String data, {String filename, double width}) {
  /// Create the Barcode
  final svg = bc.toSvg(data, width: width ?? 200);

  // Save the image
  filename ??= bc.name.replaceAll(RegExp(r'\s'), '-').toLowerCase();
  File('$filename.svg').writeAsStringSync(svg);
}

void main() {
  buildBarcode(
    Barcode.code39(),
    'CODE 39',
  );

  buildBarcode(
    Barcode.code93(),
    'CODE 93',
  );

  buildBarcode(
    Barcode.code128(useCode128B: false, useCode128C: false),
    'BARCODE\t128',
    filename: 'code-128a',
  );

  buildBarcode(
    Barcode.code128(useCode128A: false, useCode128C: false),
    'Barcode 128',
    filename: 'code-128b',
  );

  buildBarcode(
    Barcode.code128(useCode128A: false, useCode128B: false),
    '0123456789',
    filename: 'code-128c',
  );

  buildBarcode(
    Barcode.gs128(),
    '00123456780000000001',
  );

  buildBarcode(
    Barcode.itf14(),
    '1540014128876',
  );

  buildBarcode(
    Barcode.ean13(),
    '590123412345',
  );

  buildBarcode(
    Barcode.ean8(),
    '9638507',
    width: 100,
  );

  buildBarcode(
    Barcode.ean2(),
    '05',
    width: 40,
  );

  buildBarcode(
    Barcode.ean5(),
    '52495',
    width: 60,
  );

  buildBarcode(
    Barcode.isbn(),
    '978316148410',
  );

  buildBarcode(
    Barcode.upcA(),
    '98765432109',
  );

  buildBarcode(
    Barcode.upcE(),
    '06510000432',
    width: 100,
  );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  barcode: ^1.5.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:barcode/barcode.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
93
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
96
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
meta ^1.1.5 1.1.8
Dev dependencies
pedantic 1.9.0
test any