Skip to content

Commit

Permalink
[camera_platform_interface] Add torch definition to the FlashModes en…
Browse files Browse the repository at this point in the history
…um (flutter#3326)

* Fix formatting issues

* Make sure torch value is serialized correctly
  • Loading branch information
mvanbeusekom committed Dec 16, 2020
1 parent bad9fd1 commit b85d8eb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.0.4

- Added the torch option to the FlashMode enum, which when implemented indicates the flash light should be turned on continuously.

## 1.0.3

- Update Flutter SDK constraint.
Expand Down
Expand Up @@ -226,6 +226,8 @@ class MethodChannelCamera extends CameraPlatform {
return 'auto';
case FlashMode.always:
return 'always';
case FlashMode.torch:
return 'torch';
default:
throw ArgumentError('Unknown FlashMode value');
}
Expand Down
Expand Up @@ -108,7 +108,7 @@ abstract class CameraPlatform extends PlatformInterface {
throw UnimplementedError('resumeVideoRecording() is not implemented.');
}

/// Sets the flash mode for taking pictures.
/// Sets the flash mode for the selected camera.
Future<void> setFlashMode(int cameraId, FlashMode mode) {
throw UnimplementedError('setFlashMode() is not implemented.');
}
Expand Down
Expand Up @@ -12,4 +12,7 @@ enum FlashMode {

/// Always use the flash when taking a picture.
always,

/// Turns on the flash light and keeps it on until switched off.
torch,
}
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the camera plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.0.3
version: 1.0.4

dependencies:
flutter:
Expand Down
Expand Up @@ -6,10 +6,10 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
test('FlashMode should contain 3 options', () {
test('FlashMode should contain 4 options', () {
final values = FlashMode.values;

expect(values.length, 3);
expect(values.length, 4);
});

test("FlashMode enum should have items in correct index", () {
Expand All @@ -18,5 +18,6 @@ void main() {
expect(values[0], FlashMode.off);
expect(values[1], FlashMode.auto);
expect(values[2], FlashMode.always);
expect(values[3], FlashMode.torch);
});
}

0 comments on commit b85d8eb

Please sign in to comment.