Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update version number
  • Loading branch information
mvanbeusekom committed Dec 19, 2020
commit 8c9ea18f42f3313c9648e9a88dd1639f568fce79
14 changes: 13 additions & 1 deletion packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
## 0.6.1
## 0.6.2

* Add zoom support for Android and iOS implementations.

## 0.6.1+1

* Added implementation of the `didFinishProcessingPhoto` on iOS which allows saving image metadata (EXIF) on iOS 11 and up.

## 0.6.1

* Add flash support for Android and iOS implementations.

## 0.6.0+2

* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))

## 0.6.0+1

Updated README to inform users that iOS 10.0+ is needed for use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,9 @@ public class Camera {
private boolean recordingVideo;
private File videoRecordingFile;
private int currentOrientation = ORIENTATION_UNKNOWN;

// Mirrors camera.dart
public enum ResolutionPreset {
low,
medium,
high,
veryHigh,
ultraHigh,
max,
}
private Context applicationContext;
private FlashMode flashMode;
private PictureCaptureRequest pictureCaptureRequest;

public Camera(
final Activity activity,
Expand Down
2 changes: 2 additions & 0 deletions packages/camera/camera/ios/Classes/CameraPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
} else if ([@"setZoomLevel" isEqualToString:call.method]) {
CGFloat zoom = ((NSNumber *)argsMap[@"zoom"]).floatValue;
[_camera setZoomLevel:zoom Result:result];
} else if ([@"setFlashMode" isEqualToString:call.method]) {
[_camera setFlashModeWithResult:result mode:call.arguments[@"mode"]];
} else {
result(FlutterMethodNotImplemented);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/camera/camera/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,16 @@ class CameraController extends ValueNotifier<CameraValue> {
}
}

/// Sets the flash mode for taking pictures.
Future<void> setFlashMode(FlashMode mode) async {
try {
await CameraPlatform.instance.setFlashMode(_cameraId, mode);
value = value.copyWith(flashMode: mode);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
}

/// Releases the resources of this camera.
@override
Future<void> dispose() async {
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
version: 0.6.1
version: 0.6.2
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera

dependencies:
Expand Down
45 changes: 45 additions & 0 deletions packages/camera/camera/test/camera_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,51 @@ void main() {
verify(CameraPlatform.instance.setZoomLevel(mockInitializeCamera, 42.0))
.called(1);
});

test('setFlashMode() calls $CameraPlatform', () async {
CameraController cameraController = CameraController(
CameraDescription(
name: 'cam',
lensDirection: CameraLensDirection.back,
sensorOrientation: 90),
ResolutionPreset.max);
await cameraController.initialize();

await cameraController.setFlashMode(FlashMode.always);

verify(CameraPlatform.instance
.setFlashMode(cameraController.cameraId, FlashMode.always))
.called(1);
});

test('setFlashMode() throws $CameraException on $PlatformException',
() async {
CameraController cameraController = CameraController(
CameraDescription(
name: 'cam',
lensDirection: CameraLensDirection.back,
sensorOrientation: 90),
ResolutionPreset.max);
await cameraController.initialize();

when(CameraPlatform.instance
.setFlashMode(cameraController.cameraId, FlashMode.always))
.thenThrow(
PlatformException(
code: 'TEST_ERROR',
message: 'This is a test error message',
details: null,
),
);

expect(
cameraController.setFlashMode(FlashMode.always),
throwsA(isA<CameraException>().having(
(error) => error.description,
'TEST_ERROR',
'This is a test error message',
)));
});
});
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.