barcode 2.0.0-nullsafety copy "barcode: ^2.0.0-nullsafety" to clipboard
barcode: ^2.0.0-nullsafety copied to clipboard

outdated

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

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,
  double? height,
  double? fontHeight,
}) {
  /// Create the Barcode
  final svg = bc.toSvg(
    data,
    width: width ?? 200,
    height: height ?? 80,
    fontHeight: fontHeight,
  );

  // 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(),
    '(420)22345(56780000000001)',
  );

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

  buildBarcode(
    Barcode.ean13(drawEndChar: true),
    '590123412345',
  );

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

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

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

  buildBarcode(
    Barcode.isbn(drawEndChar: true),
    '978316148410',
  );

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

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

  buildBarcode(
    Barcode.telepen(),
    'Telepen',
  );

  buildBarcode(
    Barcode.qrCode(),
    'QR-Code',
    height: 200,
  );

  buildBarcode(
    Barcode.codabar(explicitStartStop: true),
    'A1234-5678B',
  );

  buildBarcode(
    Barcode.pdf417(),
    'PDF417',
    height: 30,
  );

  buildBarcode(
    Barcode.dataMatrix(),
    'Datamatrix',
    height: 200,
  );

  buildBarcode(
    Barcode.aztec(),
    'Aztec',
    height: 200,
  );

  buildBarcode(
    Barcode.rm4scc(),
    'RM4SCC',
    height: 50,
    fontHeight: 30,
  );

  buildBarcode(
    Barcode.itf(),
    '987234',
  );
}
533
likes
0
points
552k
downloads

Publisher

verified publishernfet.net

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta, qr

More

Packages that depend on barcode