Showing
1 changed file
with
5 additions
and
9 deletions
| @@ -113,17 +113,13 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | @@ -113,17 +113,13 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | ||
| 113 | /// Set the zoom scale of the camera. | 113 | /// Set the zoom scale of the camera. |
| 114 | /// | 114 | /// |
| 115 | /// The [zoomScale] must be between 0.0 and 1.0 (both inclusive). | 115 | /// The [zoomScale] must be between 0.0 and 1.0 (both inclusive). |
| 116 | + /// | ||
| 117 | + /// If the [zoomScale] is out of range, | ||
| 118 | + /// it is adjusted to fit within the allowed range. | ||
| 116 | Future<void> setZoomScale(double zoomScale) async { | 119 | Future<void> setZoomScale(double zoomScale) async { |
| 117 | - if (zoomScale < 0 || zoomScale > 1) { | ||
| 118 | - throw const MobileScannerException( | ||
| 119 | - errorCode: MobileScannerErrorCode.genericError, | ||
| 120 | - errorDetails: MobileScannerErrorDetails( | ||
| 121 | - message: 'The zoomScale must be between 0.0 and 1.0', | ||
| 122 | - ), | ||
| 123 | - ); | ||
| 124 | - } | 120 | + final double clampedZoomScale = zoomScale.clamp(0.0, 1.0); |
| 125 | 121 | ||
| 126 | - await MobileScannerPlatform.instance.setZoomScale(zoomScale); | 122 | + await MobileScannerPlatform.instance.setZoomScale(clampedZoomScale); |
| 127 | } | 123 | } |
| 128 | 124 | ||
| 129 | /// Stop the camera. | 125 | /// Stop the camera. |
-
Please register or login to post a comment