Navaron Bracke

throw unsupported errors for zoom & torch on web

... ... @@ -19,6 +19,8 @@ BREAKING CHANGES:
* The `startDelay` has been removed from the `MobileScanner` widget. Instead, use a delay between manual starts of one or more controllers.
* The `onDetect` method has been removed from the `MobileScanner` widget. Instead, listen to `MobileScannerController.barcodes` directly.
* The `overlay` widget of the `MobileScanner` has been replaced by a new property, `overlayBuilder`, which provides the constraints for the overlay.
* 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`.
* 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`.
Improvements:
* The `MobileScannerController` is now a ChangeNotifier, with `MobileScannerState` as its model.
... ...
... ... @@ -193,11 +193,35 @@ class MobileScannerWeb extends MobileScannerPlatform {
}
@override
Future<void> resetZoomScale() {
throw UnsupportedError(
'Setting the zoom scale is not supported for video tracks on the web.\n'
'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
);
}
@override
void setBarcodeLibraryScriptUrl(String scriptUrl) {
_alternateScriptUrl ??= scriptUrl;
}
@override
Future<void> setTorchState(TorchState torchState) {
throw UnsupportedError(
'Setting the torch state is not supported for video tracks on the web.\n'
'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
);
}
@override
Future<void> setZoomScale(double zoomScale) {
throw UnsupportedError(
'Setting the zoom scale is not supported for video tracks on the web.\n'
'See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks',
);
}
@override
Future<MobileScannerViewAttributes> start(StartOptions startOptions) async {
// If the permission request has not yet completed,
// the camera view is not ready yet.
... ...