DavBfr / dart_barcode

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

expose method to return text with calculated checksum #19

Closed kw2019ltd closed 3 years ago

kw2019ltd commented 3 years ago

Hi, can you expose method for ITF/EAN/UPC codes, input is barcode text and return barcode text + (checksum) if input text dose not contain checksum.

DavBfr commented 3 years ago

A version with this is available in the master branch.

use:

    final BarcodeEan ean13 = Barcode.ean13();
    final value = ean13.normalize('453987234345');
kw2019ltd commented 3 years ago

tested all fine except upce , example try to normalize 1234567 result should be 12345670 but failing with

print(Barcode.upcE().isValid("1234567")) -> print true print(barcodeEan.normalize("1234567")) - > failing below

BarcodeException: Unable to convert "1234567" to UPC E Barcode I/flutter ( 6015): SEVERE: 2020-08-17 13:41:59.180170: #0 BarcodeUpcE.upcaToUpce (package:barcode/src/upce.dart:79:7) I/flutter ( 6015): #1 BarcodeUpcE.normalize (package:barcode/src/upce.dart:370:14) I/flutter ( 6015): #2 _EanTextEditingControllerWidgetState._createManualBarcodeDto (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:264:22) I/flutter ( 6015): #3 _EanTextEditingControllerWidgetState._onPressed (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:222:19) I/flutter ( 6015): #4 _EanTextEditingControllerWidgetState.build. (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:177:31)

kw2019ltd commented 3 years ago

another example: 987456 when normalize it should be 09874565

print(Barcode.upcE().isValid("987456")) -> print true print(barcodeEan.normalize("987456")) - > failing below

DavBfr commented 3 years ago

Yes, you have to use the fallback:

print(Barcode.upcE(fallback: true).isValid("987456"))
kw2019ltd commented 3 years ago

i think iam missing something, for UPCE the code is 555555, and isValid return true.

now in barCodeWidget it display it as 05555550

but barcodeEan.normalize("555555") is failing on , why its not returning 05555550 ?

BarcodeException: Unable to convert "555555" to UPC E Barcode I/flutter ( 6015): SEVERE: 2020-08-17 13:41:59.180170: #0 BarcodeUpcE.upcaToUpce (package:barcode/src/upce.dart:79:7) I/flutter ( 6015): #1 BarcodeUpcE.normalize (package:barcode/src/upce.dart:370:14) I/flutter ( 6015): #2 _EanTextEditingControllerWidgetState._createManualBarcodeDto (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:264:22) I/flutter ( 6015): #3 _EanTextEditingControllerWidgetState._onPressed (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:222:19) I/flutter ( 6015): #4 _EanTextEditingControllerWidgetState.build. (package:barcodeapp/widget/qr_barcode/create/ean_widget.dart:177:31)

kw2019ltd commented 3 years ago

here the code is 555555 , and barcodeWidget works fine , but barcodeEan.normalize("555555") is failing Screenshot_1597766076

kw2019ltd commented 3 years ago

see also

https://online-barcode-generator.net/

image

DavBfr commented 3 years ago

@kw2019ltd Here is a fix which should work as expected now.

kw2019ltd commented 3 years ago

now its working fine, can you release new ver

thanks.

DavBfr commented 3 years ago

Done. Don't hesitate to Buy Me A Coffee.

kw2019ltd commented 3 years ago

hi you create new ver in pub?

On Thu, Aug 20, 2020 at 12:06 AM David PHAM-VAN notifications@github.com wrote:

Done. Don't hesitate to Buy Me A Coffee https://www.buymeacoffee.com/JORBmbw9h .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DavBfr/dart_barcode/issues/19#issuecomment-676703078, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6WHXNDUJDGFLIF7HRDSBQ5FTANCNFSM4QAJX7DA .

DavBfr commented 3 years ago

@kw2019ltd it's already updated: https://pub.dev/packages/barcode/changelog