Skip to content

Commit 8313444

Browse files
authored
[camera] Fixes crash when taking a picture on iOS devices without flash (flutter#3411)
1 parent 1e90b58 commit 8313444

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.0+5
2+
3+
* Fixes crash when taking a picture on iOS devices without flash.
4+
15
## 0.7.0+4
26

37
* Make sure the configured zoom scale is copied over to the final capture builder on Android. Fixes the issue where the preview is zoomed but the final picture is not.

packages/camera/camera/ios/Classes/CameraPlugin.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ - (instancetype)initWithCameraName:(NSString *)cameraName
365365
_enableAudio = enableAudio;
366366
_dispatchQueue = dispatchQueue;
367367
_captureSession = [[AVCaptureSession alloc] init];
368-
_flashMode = FlashModeAuto;
368+
_captureDevice = [AVCaptureDevice deviceWithUniqueID:cameraName];
369+
_flashMode = _captureDevice.hasFlash ? FlashModeAuto : FlashModeOff;
369370
_exposureMode = ExposureModeAuto;
370371
_focusMode = FocusModeAuto;
371372
_lockedCaptureOrientation = UIDeviceOrientationUnknown;
372373

373-
_captureDevice = [AVCaptureDevice deviceWithUniqueID:cameraName];
374374
NSError *localError = nil;
375375
_captureVideoInput = [AVCaptureDeviceInput deviceInputWithDevice:_captureDevice
376376
error:&localError];

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5-
version: 0.7.0+4
5+
version: 0.7.0+5
66
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
77

88
dependencies:

0 commit comments

Comments
 (0)