Navaron Bracke

update comment

@@ -30,8 +30,7 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -30,8 +30,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
30 BarcodeReader? _barcodeReader; 30 BarcodeReader? _barcodeReader;
31 31
32 /// The stream controller for the barcode stream. 32 /// The stream controller for the barcode stream.
33 - final StreamController<BarcodeCapture> _barcodesController =  
34 - StreamController.broadcast(); 33 + final StreamController<BarcodeCapture> _barcodesController = StreamController.broadcast();
35 34
36 /// The subscription for the barcode stream. 35 /// The subscription for the barcode stream.
37 StreamSubscription<Object?>? _barcodesSubscription; 36 StreamSubscription<Object?>? _barcodesSubscription;
@@ -45,8 +44,7 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -45,8 +44,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
45 /// because that is the only property for video tracks that can be observed. 44 /// because that is the only property for video tracks that can be observed.
46 /// 45 ///
47 /// See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks 46 /// See https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints#instance_properties_of_video_tracks
48 - final StreamController<MediaTrackSettings> _settingsController =  
49 - StreamController.broadcast(); 47 + final StreamController<MediaTrackSettings> _settingsController = StreamController.broadcast();
50 48
51 /// The texture ID for the camera view. 49 /// The texture ID for the camera view.
52 int _textureId = 1; 50 int _textureId = 1;
@@ -65,12 +63,10 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -65,12 +63,10 @@ class MobileScannerWeb extends MobileScannerPlatform {
65 Stream<BarcodeCapture?> get barcodesStream => _barcodesController.stream; 63 Stream<BarcodeCapture?> get barcodesStream => _barcodesController.stream;
66 64
67 @override 65 @override
68 - Stream<TorchState> get torchStateStream =>  
69 - _settingsController.stream.map((_) => TorchState.unavailable); 66 + Stream<TorchState> get torchStateStream => _settingsController.stream.map((_) => TorchState.unavailable);
70 67
71 @override 68 @override
72 - Stream<double> get zoomScaleStateStream =>  
73 - _settingsController.stream.map((_) => 1.0); 69 + Stream<double> get zoomScaleStateStream => _settingsController.stream.map((_) => 1.0);
74 70
75 /// Create the [HTMLVideoElement] along with its parent container [HTMLDivElement]. 71 /// Create the [HTMLVideoElement] along with its parent container [HTMLDivElement].
76 HTMLVideoElement _createVideoElement(int textureId) { 72 HTMLVideoElement _createVideoElement(int textureId) {
@@ -143,6 +139,7 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -143,6 +139,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
143 final JSArray<JSString>? facingModes = capabilities.facingModeNullable; 139 final JSArray<JSString>? facingModes = capabilities.facingModeNullable;
144 140
145 // TODO: this is an empty array on MacOS Chrome, where there is no facing mode, but one, user facing camera. 141 // TODO: this is an empty array on MacOS Chrome, where there is no facing mode, but one, user facing camera.
  142 + // We might be able to add a workaround, using the label of the video track.
146 // Facing mode is not supported by this track, do nothing. 143 // Facing mode is not supported by this track, do nothing.
147 if (facingModes == null || facingModes.toDart.isEmpty) { 144 if (facingModes == null || facingModes.toDart.isEmpty) {
148 return; 145 return;
@@ -166,14 +163,12 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -166,14 +163,12 @@ class MobileScannerWeb extends MobileScannerPlatform {
166 throw const MobileScannerException( 163 throw const MobileScannerException(
167 errorCode: MobileScannerErrorCode.unsupported, 164 errorCode: MobileScannerErrorCode.unsupported,
168 errorDetails: MobileScannerErrorDetails( 165 errorDetails: MobileScannerErrorDetails(
169 - message:  
170 - 'This browser does not support displaying video from the camera.', 166 + message: 'This browser does not support displaying video from the camera.',
171 ), 167 ),
172 ); 168 );
173 } 169 }
174 170
175 - final MediaTrackSupportedConstraints capabilities =  
176 - window.navigator.mediaDevices.getSupportedConstraints(); 171 + final MediaTrackSupportedConstraints capabilities = window.navigator.mediaDevices.getSupportedConstraints();
177 172
178 final MediaStreamConstraints constraints; 173 final MediaStreamConstraints constraints;
179 174
@@ -194,8 +189,7 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -194,8 +189,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
194 189
195 try { 190 try {
196 // Retrieving the media devices requests the camera permission. 191 // Retrieving the media devices requests the camera permission.
197 - final MediaStream videoStream =  
198 - await window.navigator.mediaDevices.getUserMedia(constraints).toDart; 192 + final MediaStream videoStream = await window.navigator.mediaDevices.getUserMedia(constraints).toDart;
199 193
200 return videoStream; 194 return videoStream;
201 } on DOMException catch (error, stackTrace) { 195 } on DOMException catch (error, stackTrace) {
@@ -204,8 +198,7 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -204,8 +198,7 @@ class MobileScannerWeb extends MobileScannerPlatform {
204 MobileScannerErrorCode errorCode = MobileScannerErrorCode.genericError; 198 MobileScannerErrorCode errorCode = MobileScannerErrorCode.genericError;
205 199
206 // Handle both unsupported and permission errors from the web. 200 // Handle both unsupported and permission errors from the web.
207 - if (errorMessage.contains('NotFoundError') ||  
208 - errorMessage.contains('NotSupportedError')) { 201 + if (errorMessage.contains('NotFoundError') || errorMessage.contains('NotSupportedError')) {
209 errorCode = MobileScannerErrorCode.unsupported; 202 errorCode = MobileScannerErrorCode.unsupported;
210 } else if (errorMessage.contains('NotAllowedError')) { 203 } else if (errorMessage.contains('NotAllowedError')) {
211 errorCode = MobileScannerErrorCode.permissionDenied; 204 errorCode = MobileScannerErrorCode.permissionDenied;