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

Commit b85d8eb

Browse files
authored
[camera_platform_interface] Add torch definition to the FlashModes enum (#3326)
* Fix formatting issues * Make sure torch value is serialized correctly
1 parent bad9fd1 commit b85d8eb

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

packages/camera/camera_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.4
2+
3+
- Added the torch option to the FlashMode enum, which when implemented indicates the flash light should be turned on continuously.
4+
15
## 1.0.3
26

37
- Update Flutter SDK constraint.

packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class MethodChannelCamera extends CameraPlatform {
226226
return 'auto';
227227
case FlashMode.always:
228228
return 'always';
229+
case FlashMode.torch:
230+
return 'torch';
229231
default:
230232
throw ArgumentError('Unknown FlashMode value');
231233
}

packages/camera/camera_platform_interface/lib/src/platform_interface/camera_platform.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ abstract class CameraPlatform extends PlatformInterface {
108108
throw UnimplementedError('resumeVideoRecording() is not implemented.');
109109
}
110110

111-
/// Sets the flash mode for taking pictures.
111+
/// Sets the flash mode for the selected camera.
112112
Future<void> setFlashMode(int cameraId, FlashMode mode) {
113113
throw UnimplementedError('setFlashMode() is not implemented.');
114114
}

packages/camera/camera_platform_interface/lib/src/types/flash_mode.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ enum FlashMode {
1212

1313
/// Always use the flash when taking a picture.
1414
always,
15+
16+
/// Turns on the flash light and keeps it on until switched off.
17+
torch,
1518
}

packages/camera/camera_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the camera plugin.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 1.0.3
6+
version: 1.0.4
77

88
dependencies:
99
flutter:

packages/camera/camera_platform_interface/test/types/flash_mode_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
66
import 'package:flutter_test/flutter_test.dart';
77

88
void main() {
9-
test('FlashMode should contain 3 options', () {
9+
test('FlashMode should contain 4 options', () {
1010
final values = FlashMode.values;
1111

12-
expect(values.length, 3);
12+
expect(values.length, 4);
1313
});
1414

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

0 commit comments

Comments
 (0)