mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

scan window not WORKING..

Open Mohammed3194 opened this issue 1 year ago • 22 comments

Hi @juliansteenbakker, @navaronbracke, @EArminjon, @hazzo,

I am using mobile_scanner plugin v3.5.2, to scan the data matrix QR code. Everything works so well thanks you everyone. But, i am facing on issue, may be i would say it is a blocker for me. When i apply a scanWindow for MobileScanner, QR code is not at all scanning. When comment out the scanWindow scanner works well..

image

I am not understanding what is going wrong, please help me fixing this issue.. Any help out be appreciated.

cc: @MBulli @woolfred @ryanduffyne @vbuberen @jlin5

Mohammed3194 avatar Feb 16 '24 09:02 Mohammed3194

Hello,

Scaffold apply some margins / paddings and also can contain an AppBar. I suggest first of all to not use the context of MediaQuery but the closest context near MobileScanner.

Wrap your MobileScanner with a LayoutBuilder() and then use this context to compute the size of your scanWindow.

I didn't know if it will fix your issue but anyway, it will help.

EArminjon avatar Feb 16 '24 09:02 EArminjon

Thank you for the report. Does the example app sample with the scan window work for you? If that one does work, then, as stated above, I suggest checking which BuildContext you use to determine the scan window.

Also, I would advise not to tag everyone on this issue, as to not distract people with notifications and such.

navaronbracke avatar Feb 16 '24 10:02 navaronbracke

Hello,

Scaffold apply some margins / paddings and also can contain an AppBar. I suggest first of all to not use the context of MediaQuery but the closest context near MobileScanner.

Wrap your MobileScanner with a LayoutBuilder() and then use this context to compute the size of your scanWindow.

I didn't know if it will fix your issue but anyway, it will help.

@EArminjon - I did wrap the MobileScanner with LayoutBuilder() and used builder context. But, still the same, QR is not picking up :(

Updated Code:

image

Mohammed3194 avatar Feb 16 '24 11:02 Mohammed3194

Thank you for the report. Does the example app sample with the scan window work for you? If that one does work, then, as stated above, I suggest checking which BuildContext you use to determine the scan window.

Also, I would advise not to tag everyone on this issue, as to not distract people with notifications and such.

@navaronbracke - Sorry, for tagging everyone. Yes, the example app sample works fine with scan windows.

Mohammed3194 avatar Feb 16 '24 11:02 Mohammed3194

Try constraints instead of MediaQuery ?

EArminjon avatar Feb 16 '24 11:02 EArminjon

Also stopped working when enabling impeller on android, without works

Shakle avatar Feb 16 '24 17:02 Shakle

@Shakle Impeller on Android is still in preview, so issues with the Texture registry are expected at this point (hence it's a preview)

navaronbracke avatar Feb 16 '24 18:02 navaronbracke

Try constraints instead of MediaQuery ?

@EArminjon Yes, tried no luck..

Sorry, I missed you mentioned you that MobileScanner is wrapped inside the FutureBuilder. Where FutureBuilder is the parent widget and MobileScanner is the Nested widget.

Does this make any difference ?

cc: @navaronbracke

Mohammed3194 avatar Feb 19 '24 11:02 Mohammed3194

That should not make any difference, in that case just use the BuildContext of the FutureBuilder ?

navaronbracke avatar Feb 19 '24 11:02 navaronbracke

That should not make any difference, in that case just use the BuildContext of the FutureBuilder ?

Not working :( :(

Mohammed3194 avatar Feb 19 '24 12:02 Mohammed3194

What is the rectangle value for your scan window? Maybe it is in the wrong position?

navaronbracke avatar Feb 19 '24 12:02 navaronbracke

Can you post a complete minimal working example? Starting from the main() function, including only the relevant widgets to reproduce the problem?

MBulli avatar Feb 21 '24 07:02 MBulli

Can you post a complete minimal working example? Starting from the main() function, including only the relevant widgets to reproduce the problem?

Sure, will share..

Mohammed3194 avatar Feb 23 '24 07:02 Mohammed3194

@Mohammed3194 Can you test version 5.0.0-beta.2 ? I made a bugfix for the scan window, which was not updated when the rectangle itself changed dimensions.

navaronbracke avatar Mar 21 '24 10:03 navaronbracke

@navaronbracke

I have problem with the scanWidow too.

I'm trying to use the beta version: 5.0.0-beta.2

But these function doesn't exist (MobileScanner constructor):

  • onDetect
  • onScannerStarted (I'm using it for setting initial zoom scale)

Do you have any docs about it?

burekas7 avatar Apr 09 '24 15:04 burekas7

Instead of using onDetect, listen to the Stream<BarcodeCapture> that is provided by the controller. Since you now manually start the controller, onScannerStarted no longer exists. Instead do the following:

await controller.start();
// set the zoom scale after the controller started

navaronbracke avatar Apr 09 '24 16:04 navaronbracke

@navaronbracke

Regarding the bug. It seems that it ignores the "center" value, or maybe the whole scanWindow (I modified the Offsets value)

(Using 5.0.0 beta)

burekas7 avatar Apr 09 '24 17:04 burekas7

What do you mean by that? The scanWindow is a rectangle that is relative to the camera output.

If I understand correctly, if scanWindow is set, a barcode must have its points inside that rectangle.

navaronbracke avatar Apr 09 '24 18:04 navaronbracke

@navaronbracke

I took this from your example:

    final scanWindow = Rect.fromCenter(
      center: MediaQuery.sizeOf(context).center(Offset.zero),
      width: 200,
      height: 200,
    );

But when I change the Offset it still read from the same area as Offset.zero.

burekas7 avatar Apr 09 '24 18:04 burekas7

@navaronbracke

Update: It's working :)

burekas7 avatar Apr 09 '24 18:04 burekas7

Just so I understand, what was the problem you were facing with the offset?

navaronbracke avatar Apr 09 '24 18:04 navaronbracke

@navaronbracke I implement the "Target" for scanning with another class (It's not just a transparent window as you did) So I was need to debug where exactly is the center, and then I fix the offset for the Mobile Scanner.

By the way, your "Target" in your example is not good, the window is showing at the bottom-right of the screen and very very small.

burekas7 avatar Apr 09 '24 21:04 burekas7