Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On iPad availableCameras() does not return #49

Open
2math opened this issue Apr 6, 2022 · 2 comments
Open

On iPad availableCameras() does not return #49

2math opened this issue Apr 6, 2022 · 2 comments

Comments

@2math
Copy link

2math commented Apr 6, 2022

Hi thanks for this great plugin.
I have an issue on iPads only.
When I try to initialise the camera it stops at await availableCameras();
Has anyone seen such problem?

Thanks in advance!

Testing on iPad 9th 15.3.1 and iPad mini 5th Generation 15.4

flutter_better_camera: ^1.0.2+1

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.2.1 21D62 darwin-x64, locale en-BG)
• Flutter version 2.5.3 at /Users/galeen/soft/flutter2
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (6 months ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.3, Build version 13E113
• CocoaPods version 1.11.2

void initializeCameraController() async {
    Log.d("initializeCameraController", tag);
    try {
      var cameras = await availableCameras();
      
      //this log is never called on iPad
      Log.d("cameras $cameras", tag);

      var resolutionPreset = getResolutionPreset();

      if (resolutionPreset == null) {
            Log.d("Missing resolutionPreset", tag);

            return;
          }

      cameraController = CameraController(cameras[0], resolutionPreset,
              enableAudio: false, enableAutoExposure: false, autoFocusEnabled: true);

      await PermissionHandlerService().requestCameraPermission(
              onHasPermission: _initCamera,
              onShowExplainDialog: () {
                add(ShowPermissionDialog());
              },
          tag: tag);
    } catch (e) {
      Log.error("initializeCameraController", error: e, tag: tag);
    }
  }
@2math
Copy link
Author

2math commented Apr 7, 2022

Now this is interesting, for version 1.0.0 and 1.0.1 I can initialise the camera and take images. It only crashes when want to set the flash on. I'm looking at latest commits for 1.0.2 and 1.0.2+1 and don't see much of a changes. However can not get available cameras to init the plugin for some reason. Maybe for now will check if I'm on a tablet and hide the flash options. I home with next version the plugin will work on iPads.

PS: With this plug I can check if Flash is available https://pub.dev/packages/torch_light

@splendourbell
Copy link

[self setFlashMode: AVCaptureFlashModeOff];
all allways loop . ipad not support flashmode, => _flashMode = AVCaptureFlashModeOff;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants