mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

setZoomScale doesn't work on iPhone 12 Pro

Open schilken opened this issue 1 year ago • 6 comments

With this initialization of MobileScannerController:

@override
  void initState() {
    super.initState();
    _detectedSerial = '';
    _cameraController = MobileScannerController(
      formats: [
        BarcodeFormat.all,
      ],
      detectionSpeed: DetectionSpeed.noDuplicates,
      detectionTimeoutMs: 1000,
      returnImage: false,
      autoStart: false,
    );
    _cameraController.events?.onData((data) {
      debugPrint('_cameraController.events: $data');
    });
    _cameraController.start();
    _cameraController.setZoomScale(0.8);
  }

I get an exception:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(MobileScanner, Error while zooming., null, null)

and the image is very small, not easy to scan small QR-codes of about 3cm sides.

Isn't anyone else having this problem?

I'm using Dart3 and Flutter 3.10.3, iOS 16.5.

schilken avatar Jun 12 '23 08:06 schilken

I have the same issue, this issue is caused by the version 3.2.0 that default using ultra-wide camera in my iPhone 12 pro.

I found there is a PR fixed and merged, however, the latest 3.2.0 build don't have it

  • #592

I think you need to point the library to the master branch or the latest commit in pubspec.yaml and the reinstall it

  mobile_scanner:
    git:
      url: https://github.com/juliansteenbakker/mobile_scanner
      ref: master

latest commit of master

  mobile_scanner:
    git:
      url: https://github.com/juliansteenbakker/mobile_scanner
      ref: 5aa2c11915467b19dfc5fd3a9e59641d2958ffeb

gaplo917 avatar Jun 13 '23 07:06 gaplo917

@gaplo917 Thanks - I will try the master. I guess this will be fixed in the next version of pub.dev.

schilken avatar Jun 13 '23 12:06 schilken

With the master the zoom factor is much better. 👍

schilken avatar Jun 13 '23 13:06 schilken

The fix has been released, is that still an issue @schilken @gaplo917 @juliansteenbakker ? https://github.com/juliansteenbakker/mobile_scanner/releases/tag/v3.3.0

teolemon avatar Jun 30 '23 09:06 teolemon

I'm sorry for not getting back to you sooner. I still get an PlatformException: PlatformException(MobileScanner, Error while zooming., null, null) on iPhone 12 Pro. Now with Flutter 3.13.7 and mobile_scanner: ^3.5.1

I removed the setZoomScale, which seems to be ok, at least on iOS and iPhone 12 Pro.

    _cameraController.start();
//    _cameraController.setZoomScale(1.0);

schilken avatar Oct 31 '23 14:10 schilken

On iOS, I think you might want to give it some delay after starting. I think there is a thread about this. I am faced with the same issue, it seems like the it should work without any delay but it doesn't atm for me as well;

MobileScanner(
   onScannerStarted: (_) {
       Future.delayed(const Duration(milliseconds: 50), () {
            scannerController.setZoomScale(...);
});

Here it is https://github.com/juliansteenbakker/mobile_scanner/issues/576#issuecomment-1587654861

unpluggedk avatar Dec 01 '23 02:12 unpluggedk