Navaron Bracke

remove cast on media stream

@@ -121,24 +121,12 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -121,24 +121,12 @@ class MobileScannerWeb extends MobileScannerPlatform {
121 // Retrieving the media devices requests the camera permission. 121 // Retrieving the media devices requests the camera permission.
122 _permissionRequestInProgress = true; 122 _permissionRequestInProgress = true;
123 123
124 - final MediaStream? videoStream = await window.navigator.mediaDevices  
125 - .getUserMedia(constraints)  
126 - .toDart as MediaStream?; 124 + final MediaStream videoStream =
  125 + await window.navigator.mediaDevices.getUserMedia(constraints).toDart;
127 126
128 // At this point the permission is granted. 127 // At this point the permission is granted.
129 _permissionRequestInProgress = false; 128 _permissionRequestInProgress = false;
130 129
131 - if (videoStream == null) {  
132 - throw const MobileScannerException(  
133 - errorCode: MobileScannerErrorCode.genericError,  
134 - errorDetails: MobileScannerErrorDetails(  
135 - message:  
136 - 'Could not create a video stream from the camera with the given options. '  
137 - 'The browser might not support the given constraints.',  
138 - ),  
139 - );  
140 - }  
141 -  
142 return videoStream; 130 return videoStream;
143 } on DOMException catch (error, stackTrace) { 131 } on DOMException catch (error, stackTrace) {
144 final String errorMessage = error.toString(); 132 final String errorMessage = error.toString();