Skip to content

Camera throws error when flash has been turned on in IOS #151453

@ghost

Description

Steps to reproduce

turn on the torch in IOS
tried to capture
Screenshot 2024-07-09 at 12 02 33 PM
app getting crashed with these error.
without torch it is working Okay.

Expected results

It should be work as normal and return the captured Image path as it is working Okay without torch.

Actual results

It should be work as normal and return the captured Image path as it is working Okay without torch.

Code sample

Future _captureImage() async {
if (_isCapturing) {
print('A capture is already in progress.');
return;
}

if (_controller != null && _isCameraInitialized) {
  try {
    _isCapturing = true; // Set capturing flag to true

    final image = await _controller!.takePicture();

    final cropppedImage =
        await ImageCropper().cropImage(sourcePath: image.path, uiSettings: [
      AndroidUiSettings(
        toolbarTitle: 'Image Cropper',
        toolbarColor: Colors.deepOrange,
        toolbarWidgetColor: Colors.white,
        aspectRatioPresets: [
          CropAspectRatioPreset.original,
          CropAspectRatioPreset.square,
          CropAspectRatioPresetCustom()
        ],
      ),
      IOSUiSettings(
        title: 'Image Cropper',
        aspectRatioPresets: [
          CropAspectRatioPreset.original,
          CropAspectRatioPreset.square,
        ],
      ),
      // ignore: use_build_context_synchronously
      WebUiSettings(context: context)
    ]);

    if (cropppedImage != null) {
      setState(() {
        _capturedImages.add(cropppedImage.path);
      });
      print('Image captured and cropped: ${cropppedImage.path}');
    } else {
      print('Image cropping cancelled');
    }

    await _controller!.setFlashMode(_currentFlashMode);
  } catch (e) {
    print('Error capturing image: $e');
  } finally {
    _isCapturing = false; // Reset capturing flag
  }
} else {
  print("Hello");
}

}

This both are workign

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Screenshot 2024-07-09 at 12 05 40 PM

Flutter Doctor output

ankitkhaire@Ankits-Mac-Mini-3 SmartFinDoc-Mobile % flutter doctor -v
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-IN)
• Flutter version 3.22.2 on channel stable at /Users/ankitkhaire/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747b (5 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/ankitkhaire/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_SDK_ROOT = /Users/ankitkhaire/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.14.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.91.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.92.0

[✓] Connected device (5 available)
• iPhone X (mobile) • 00008020-0011150911A2002E • ios • iOS 17.1.2 21B101
• iPhone 13 pro max (mobile) • 00008110-001938DA14F2401E • ios • iOS 17.5.1 21F90
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127
! Error: Browsing on the local area network for iPhone 13. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Nimble’s iPad. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowfound in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24fyi-ecosystemFor the attention of Ecosystem teamhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions