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

Commit a770961

Browse files
committed
Added method to retrieve min supported zoom level
1 parent 1b77854 commit a770961

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ class MethodChannelCamera extends CameraPlatform {
181181
<String, dynamic>{'cameraId': cameraId},
182182
);
183183

184+
@override
185+
Future<double> getMinZoomLevel(int cameraId) => _channel.invokeMethod<double>(
186+
'getMinZoomLevel',
187+
<String, dynamic>{'cameraId': cameraId},
188+
);
189+
184190
@override
185191
Future<void> setZoomLevel(int cameraId, double zoom) async {
186192
try {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ abstract class CameraPlatform extends PlatformInterface {
113113
throw UnimplementedError('getMaxZoomLevel() is not implemented.');
114114
}
115115

116+
/// Gets the minimum supported zoom level for the selected camera.
117+
Future<double> getMinZoomLevel(int cameraId) {
118+
throw UnimplementedError('getMinZoomLevel() is not implemented.');
119+
}
120+
116121
/// Set the zoom level for the selected camera.
117122
///
118123
/// The supplied [zoom] value should be between 1.0 and the maximum supported

packages/camera/camera_platform_interface/test/camera_platform_interface_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ void main() {
225225
);
226226
});
227227

228+
test(
229+
'Default implementation of getMinZoomLevel() should throw unimplemented error',
230+
() {
231+
// Arrange
232+
final cameraPlatform = ExtendsCameraPlatform();
233+
234+
// Act & Assert
235+
expect(
236+
() => cameraPlatform.getMinZoomLevel(1),
237+
throwsUnimplementedError,
238+
);
239+
});
240+
228241
test(
229242
'Default implementation of setZoomLevel() should throw unimplemented error',
230243
() {

packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,25 @@ void main() {
506506
]);
507507
});
508508

509+
test('Should get the min zoom level', () async {
510+
// Arrange
511+
MethodChannelMock channel = MethodChannelMock(
512+
channelName: 'plugins.flutter.io/camera',
513+
methods: {'getMinZoomLevel': 1.0},
514+
);
515+
516+
// Act
517+
final maxZoomLevel = await camera.getMinZoomLevel(cameraId);
518+
519+
// Assert
520+
expect(maxZoomLevel, 1.0);
521+
expect(channel.log, <Matcher>[
522+
isMethodCall('getMinZoomLevel', arguments: {
523+
'cameraId': cameraId,
524+
}),
525+
]);
526+
});
527+
509528
test('Should set the zoom level', () async {
510529
// Arrange
511530
MethodChannelMock channel = MethodChannelMock(

0 commit comments

Comments
 (0)