Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[camera_platform_interface] Add torch definition to the FlashModes enum #3326

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
});
}