shaxxx / flutter_barcode_listener

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

Email string @ symbol is returned as "2" #11

Closed blackbeario closed 1 year ago

blackbeario commented 2 years ago

Hey, thanks for this package! I'm scanning 2D barcodes in a variety of formats, QR Codes and Data Matrix (doesn't seem to work in my tests with Aztec format but that's another issue).

I'm generating 2D barcodes with name, age, and email strings. While on the Flutter stable channel, the results were returned wrong nearly every time. But after switching to the Flutter Beta channel the results are correct except for the email string. Specifically the @ symbol is returned as "2".

If I add a barcode with the email me@gmail.com, the plugin returns me2gmail.com every time. I don't know much about this plugin yet, but will see if I can figure it out.

For reference, I'm using a Netum NSL5S USB scanner on a Mac. The scanner works perfectly every time while in a text editing application.

Flutter (Channel beta, 2.9.0-0.1.pre, on macOS 11.2 20D64 darwin-x64, locale en-US)

danielroek commented 2 years ago

Hey @blackbeario,

In the plugin this is the line that handles the MacOS keyEvent:

...
      } else if (keyEvent.data is RawKeyEventDataMacOs) {
        _controller.sink
            .add(((keyEvent.data) as RawKeyEventDataMacOs).keyLabel);
      }

The problem here is that we listen to the keyLabel, which is '2'. I've created a PR(#13) that listens to character instead. I don't have access to a MacOs device any time soon, would you be able to test if this works?

You'd be able to test this by changing the dependency in pubspec.yaml to:

  flutter_barcode_listener:
    git:
      url: https://github.com/danielroek/flutter_barcode_listener.git
      ref: mac_os_characters
shaxxx commented 1 year ago

This is merged. Closing.