mobile_scanner
mobile_scanner copied to clipboard
scan window not WORKING..
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..
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
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.
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.
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:
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.
Try constraints instead of MediaQuery ?
Also stopped working when enabling impeller on android, without works
@Shakle Impeller on Android is still in preview, so issues with the Texture registry are expected at this point (hence it's a preview)
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
That should not make any difference, in that case just use the BuildContext
of the FutureBuilder
?
That should not make any difference, in that case just use the
BuildContext
of theFutureBuilder
?
Not working :( :(
What is the rectangle value for your scan window? Maybe it is in the wrong position?
Can you post a complete minimal working example? Starting from the main() function, including only the relevant widgets to reproduce the problem?
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 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
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?
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
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)
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
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.
@navaronbracke
Update: It's working :)
Just so I understand, what was the problem you were facing with the offset?
@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.