shaxxx / flutter_barcode_listener

Flutter widget to listen for scanned barcode via hardware scanners
MIT License
46 stars 47 forks source link

The bar code is missing and cannot be identified completely #1

Closed zouxianbincc closed 3 years ago

zouxianbincc commented 3 years ago

Hello I'm glad to find your open source project However, during the testing process, The bar code is missing and cannot be identified completely

shaxxx commented 3 years ago

Not sure what exactly is the problem? Is barcode missing or is it not identified completely? These are two distinct cases. If you're missing part of the barcode have you tried to specify bufferDuration parameter to something longer, IE. 500 ms?

zouxianbincc commented 3 years ago

Bar code missing Correct: 6901028225168 Identified: 690028225158 There are fewer digits in the middle

shaxxx commented 3 years ago

Have you tried modifing bufferDuration parameter?

pon, 1. ožu 2021. 10:21 zouxianbincc notifications@github.com je napisao:

Bar code missing Correct: 6901028225168 Identified: 690028225158 There are fewer digits in the middle

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shaxxx/flutter_barcode_listener/issues/1#issuecomment-787796535, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANSJO4K3F4MPI22ZSAA4ALTBNMCVANCNFSM4YMEU46A .

zouxianbincc commented 3 years ago

const Duration aSecond = Duration(seconds: 1); const Duration hundredMs = Duration(milliseconds: 500); const int lineFeed = 10;

我改了hundredMs=500 但是测试结果,还是一样。 数字还是出现缺失

zouxianbincc commented 3 years ago

Thank you very much. After testing, change RawKeyUpEvent to RawKeyDownEvent It can be correctly identified

zouxianbincc commented 3 years ago

void _keyBoardCallback(RawKeyEvent keyEvent) { if (keyEvent.logicalKey.keyId > 255 && keyEvent.data.logicalKey != LogicalKeyboardKey.enter) return; if (keyEvent is RawKeyDownEvent) { if (keyEvent.data != null) { if (keyEvent.data is RawKeyEventDataAndroid) { _controller.sink.add(((keyEvent.data) as RawKeyEventDataAndroid).codePoint); } else if (keyEvent.data is RawKeyEventDataFuchsia) { _controller.sink .add(((keyEvent.data) as RawKeyEventDataFuchsia).codePoint); } else if (keyEvent.data.logicalKey == LogicalKeyboardKey.enter) { _controller.sink.add(lineFeed); } } else { _controller.sink.add(keyEvent.logicalKey.keyId); } } }

shaxxx commented 3 years ago

Glad it worked. If you check history you'll see I started with KeyDown but moved to KeyUp because there were some issues. Don't remember why anymore.