Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose method to return text with calculated checksum #19

Closed
kw2019ltd opened this issue Aug 15, 2020 · 12 comments
Closed

expose method to return text with calculated checksum #19

kw2019ltd opened this issue Aug 15, 2020 · 12 comments

Comments

@kw2019ltd
Copy link

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
Copy link
Owner

DavBfr commented Aug 17, 2020

A version with this is available in the master branch.

use:

    final BarcodeEan ean13 = Barcode.ean13();
    final value = ean13.normalize('453987234345');

@kw2019ltd
Copy link
Author

kw2019ltd commented Aug 17, 2020

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
Copy link
Author

another example: 987456 when normalize it should be 09874565

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

@DavBfr
Copy link
Owner

DavBfr commented Aug 17, 2020

Yes, you have to use the fallback:

print(Barcode.upcE(fallback: true).isValid("987456"))

@kw2019ltd
Copy link
Author

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
Copy link
Author

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

@kw2019ltd
Copy link
Author

see also

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

image

@DavBfr
Copy link
Owner

DavBfr commented Aug 18, 2020

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

@kw2019ltd
Copy link
Author

now its working fine, can you release new ver

thanks.

@DavBfr
Copy link
Owner

DavBfr commented Aug 19, 2020

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

@DavBfr DavBfr closed this as completed Aug 19, 2020
@kw2019ltd
Copy link
Author

kw2019ltd commented Aug 20, 2020 via email

@DavBfr
Copy link
Owner

DavBfr commented Aug 20, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants