-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[camerax] Implement setZoomLevel
#4950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dec3d69
0e0333b
bd7ac99
5c3363b
fed9621
5aabe34
2b9a352
a1173da
cbc3d6b
cae5a4c
72283db
166a77c
399780e
8d5d0e7
084d960
d2a59ac
a1422bf
bdd87a6
137a28b
bc0db5a
d04b466
a9cfe87
a32def1
4785148
7a8fc69
b02e15f
c6e5868
0c0065a
9dfe259
bfcc0df
b80cc86
915332e
22ea65f
ad46f47
6396ec5
cd0dc35
9c9922b
0f64164
dc5f95b
743c853
85e3da7
476d4de
b385f1a
fb7986d
87a4438
12ce00c
a6f0968
cef5f31
81e6cbc
2534eae
bb0e9d7
7133289
93317eb
a08b7a3
f87e367
8b4094b
1ff09a6
96ad199
d3f245e
2aadc7c
ae695b5
9644718
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 0.5.0+20 | ||
|
|
||
| * Implements `setZoomLevel`. | ||
|
|
||
| ## 0.5.0+19 | ||
|
|
||
| * Implements torch flash mode. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,22 @@ class CameraControl extends JavaObject { | |
| late final _CameraControlHostApiImpl _api; | ||
|
|
||
| /// Enables or disables the torch of related [Camera] instance. | ||
| /// | ||
| /// If the torch mode was unable to be changed, an error message will be | ||
| /// added to [SystemServices.cameraErrorStreamController]. | ||
| Future<void> enableTorch(bool torch) async { | ||
| return _api.enableTorchFromInstance(this, torch); | ||
| } | ||
|
|
||
| /// Sets zoom of related [Camera] by ratio. | ||
| /// | ||
| /// Ratio should be between what the `minZoomRatio` and `maxZoomRatio` of the | ||
| /// [ZoomState] of the [CameraInfo] instance that is retrievable from the same | ||
| /// [Camera] instance; otherwise, an error message will be added to | ||
| /// [SystemServices.cameraErrorStreamController]. | ||
| Future<void> setZoomRatio(double ratio) async { | ||
| return _api.setZoomRatioFromInstance(this, ratio); | ||
| } | ||
| } | ||
|
|
||
| /// Host API implementation of [CameraControl]. | ||
|
|
@@ -69,6 +82,18 @@ class _CameraControlHostApiImpl extends CameraControlHostApi { | |
| .add(e.message ?? 'The camera was unable to change torch modes.'); | ||
| } | ||
| } | ||
|
|
||
| /// Sets zoom of specified [CameraControl] instance by ratio. | ||
| Future<void> setZoomRatioFromInstance( | ||
| CameraControl instance, double ratio) async { | ||
| final int identifier = instanceManager.getIdentifier(instance)!; | ||
| try { | ||
| await setZoomRatio(identifier, ratio); | ||
| } on PlatformException catch (e) { | ||
| SystemServices.cameraErrorStreamController.add(e.message ?? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will lose the stack trace right? It looks like we are doing this in other places as well (I probably missed this in earlier reviews), but do we want to include the stack trace in the message as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true, but this follows suit from the other camera platform implementations. I would argue that it's okay that we don't include it because we should only be catching camera errors like this when the camera was unable to complete the operation and not due to a code error. If you feel strongly though, I don't think it would hurt to include! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No strong feelings either way! |
||
| 'Zoom ratio was unable to be set. If ratio was not out of range, newer value may have been set; otherwise, the camera may be closed.'); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Flutter API implementation of [CameraControl]. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just taking out for now as they do cause errors.