Giter Site home page Giter Site logo

Comments (6)

Guillaume-Fortin avatar Guillaume-Fortin commented on May 24, 2024 1

yes, it's possible if your printer support this barcode format.

i tested sucessfully on TP50 Oxhoo printer.

  /// CODE128
  static const code128 = BarcodeType._internal(73);

/// CODE128
  ///
  /// k >= 2
  /// d: '{A'/'{B'/'{C' => '0'–'9', A–D, a–d, $, +, −, ., /, :
  Barcode.code128(List<dynamic> barcodeData) {
    final k = barcodeData.length;
    if (k < 2) {
      throw Exception('Barcode: Wrong data range');
    }

    final regex = RegExp(r'^\{[A-C][\x00-\x7F]+$');
    final bool isDataValid = barcodeData.every((dynamic d) => regex.hasMatch(d.toString()));
    if (!isDataValid) {
      throw Exception('Barcode: Data is not valid');
    }

    _type = BarcodeType.code128;
    _data = _convertData(barcodeData);
  }

and i change barcode method:

rawBytes(header + barcode.data + [0]);

by

if(barcode.type.value <= 6){
      rawBytes(header + barcode.data + [0]);
    }
    else{      
      rawBytes(header + [barcode.data.length] + barcode.data);
    }

usage:
{A = QRCode type A
{B = QRCode type B
{C = QRCode type C

final List barcodeData = "{A978020137962".split("");
Barcode barCode = Barcode.code128(barcodeData);
ticket.barcode(barCode);

from esc_pos_printer.

Guillaume-Fortin avatar Guillaume-Fortin commented on May 24, 2024 1

@andrey-ushakov i can give you the code for print qr code in few days

from esc_pos_printer.

andrey-ushakov avatar andrey-ushakov commented on May 24, 2024

@Thetyne thank you!

Can I add your code to the next release, please? Later I will create a Contributors section in README.md and add your GitHub nickname / link.

BTW, I think this line
final bool isDataValid = barcodeData.every((dynamic d) => regex.hasMatch(d.toString()));

should be changed by
final bool isDataValid = regex.hasMatch(barcodeData.join());

from esc_pos_printer.

Guillaume-Fortin avatar Guillaume-Fortin commented on May 24, 2024

@andrey-ushakov yes you can add it!

from esc_pos_printer.

andrey-ushakov avatar andrey-ushakov commented on May 24, 2024

That would be awesome!

from esc_pos_printer.

andrey-ushakov avatar andrey-ushakov commented on May 24, 2024

CODE128 added to the latest release.

from esc_pos_printer.

Related Issues (20)

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.