Navaron Bracke

throw unsupported errors for zoom & torch on web

@@ -19,6 +19,8 @@ BREAKING CHANGES: @@ -19,6 +19,8 @@ BREAKING CHANGES:
19 * The `startDelay` has been removed from the `MobileScanner` widget. Instead, use a delay between manual starts of one or more controllers. 19 * The `startDelay` has been removed from the `MobileScanner` widget. Instead, use a delay between manual starts of one or more controllers.
20 * The `onDetect` method has been removed from the `MobileScanner` widget. Instead, listen to `MobileScannerController.barcodes` directly. 20 * The `onDetect` method has been removed from the `MobileScanner` widget. Instead, listen to `MobileScannerController.barcodes` directly.
21 * The `overlay` widget of the `MobileScanner` has been replaced by a new property, `overlayBuilder`, which provides the constraints for the overlay. 21 * The `overlay` widget of the `MobileScanner` has been replaced by a new property, `overlayBuilder`, which provides the constraints for the overlay.
  22 +* The torch can no longer be toggled on the web, as this is only available for image tracks and not video tracks. As a result the torch state for the web will always be `TorchState.unavailable`.
  23 +* The zoom scale can no longer be modified on the web, as this is only available for image tracks and not video tracks. As a result, the zoom scale will always be `1.0`.
22 24
23 Improvements: 25 Improvements:
24 * The `MobileScannerController` is now a ChangeNotifier, with `MobileScannerState` as its model. 26 * The `MobileScannerController` is now a ChangeNotifier, with `MobileScannerState` as its model.
@@ -193,11 +193,35 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -193,11 +193,35 @@ class MobileScannerWeb extends MobileScannerPlatform {
193 } 193 }
194 194
195 @override 195 @override
  196 + Future<void> resetZoomScale() {
  197 + throw UnsupportedError(
  198 + 'Setting the zoom scale is not supported for video tracks on the web.\n'
  199 + 'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
  200 + );
  201 + }
  202 +
  203 + @override
196 void setBarcodeLibraryScriptUrl(String scriptUrl) { 204 void setBarcodeLibraryScriptUrl(String scriptUrl) {
197 _alternateScriptUrl ??= scriptUrl; 205 _alternateScriptUrl ??= scriptUrl;
198 } 206 }
199 207
200 @override 208 @override
  209 + Future<void> setTorchState(TorchState torchState) {
  210 + throw UnsupportedError(
  211 + 'Setting the torch state is not supported for video tracks on the web.\n'
  212 + 'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
  213 + );
  214 + }
  215 +
  216 + @override
  217 + Future<void> setZoomScale(double zoomScale) {
  218 + throw UnsupportedError(
  219 + 'Setting the zoom scale is not supported for video tracks on the web.\n'
  220 + 'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
  221 + );
  222 + }
  223 +
  224 + @override
201 Future<MobileScannerViewAttributes> start(StartOptions startOptions) async { 225 Future<MobileScannerViewAttributes> start(StartOptions startOptions) async {
202 // If the permission request has not yet completed, 226 // If the permission request has not yet completed,
203 // the camera view is not ready yet. 227 // the camera view is not ready yet.