DavBfr / dart_barcode

Barcode generation library
https://pub.dev/packages/barcode
Apache License 2.0
134 stars 39 forks source link

Ean2 barcode error in v2.2.4. #64

Closed shinbin closed 8 months ago

shinbin commented 9 months ago

Hello author, I would like to report that the barcode content generated by ean2 is wrong in v2.2.4 . The data content is such as "12" or "48", etc., resulting in an incorrect ean2 barcode. I have used Scanner to scan EAN8 with EAN2 addon and other barcode tests. I also refer to the EAN2 content generated by professional barcode software or websites ( 'https://www.online-barcode.com/'). The EAN2 barcodes produced by these sources are different from v2.2.4. Please help with the revision, thank you very much. ean2-err

shinbin commented 9 months ago

I refer to https://en.wikipedia.org/wiki/EAN-2 , and modified convert(String data) function,

Changed =>

yield* add(codes[((pattern >> index) & 1) ^ 1], 7);

Replaced to =>

if(index == 0){ yield add(codes[pattern < 2 ? 0 : 1], 7); } else { yield add(codes[pattern % 2 == 0 ? 0 : 1], 7); }

In this way, the EAN2 barcode can be generated correctly. Please the author also modify the barcode 2.2.4 package, and update it to https://pub.dev/packages/barcode . Let's reference this library directly. Thanks.

DavBfr commented 9 months ago

@shinbin Please create a Pull Request.

shinbin commented 9 months ago

@DavBfr Thanks for the guidance, I've created a Pull Request.

DavBfr commented 8 months ago

Fixed.