Showing
4 changed files
with
1 additions
and
40 deletions
| @@ -11,8 +11,7 @@ export 'src/enums/phone_type.dart'; | @@ -11,8 +11,7 @@ export 'src/enums/phone_type.dart'; | ||
| 11 | export 'src/enums/torch_state.dart'; | 11 | export 'src/enums/torch_state.dart'; |
| 12 | export 'src/mobile_scanner.dart'; | 12 | export 'src/mobile_scanner.dart'; |
| 13 | export 'src/mobile_scanner_controller.dart'; | 13 | export 'src/mobile_scanner_controller.dart'; |
| 14 | -export 'src/mobile_scanner_exception.dart' | ||
| 15 | - hide PermissionRequestPendingException; | 14 | +export 'src/mobile_scanner_exception.dart'; |
| 16 | export 'src/mobile_scanner_platform_interface.dart'; | 15 | export 'src/mobile_scanner_platform_interface.dart'; |
| 17 | export 'src/objects/address.dart'; | 16 | export 'src/objects/address.dart'; |
| 18 | export 'src/objects/barcode.dart'; | 17 | export 'src/objects/barcode.dart'; |
| @@ -242,13 +242,6 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | @@ -242,13 +242,6 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | ||
| 242 | ); | 242 | ); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | - // Permission was denied, do nothing. | ||
| 246 | - // When the controller is stopped, | ||
| 247 | - // the error is reset so the permission can be requested again if possible. | ||
| 248 | - if (value.error?.errorCode == MobileScannerErrorCode.permissionDenied) { | ||
| 249 | - return; | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | // Do nothing if the camera is already running. | 245 | // Do nothing if the camera is already running. |
| 253 | if (value.isRunning) { | 246 | if (value.isRunning) { |
| 254 | return; | 247 | return; |
| @@ -301,8 +294,6 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | @@ -301,8 +294,6 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | ||
| 301 | zoomScale: 1.0, | 294 | zoomScale: 1.0, |
| 302 | ); | 295 | ); |
| 303 | } | 296 | } |
| 304 | - } on PermissionRequestPendingException catch (_) { | ||
| 305 | - // If a permission request was already pending, do nothing. | ||
| 306 | } | 297 | } |
| 307 | } | 298 | } |
| 308 | 299 |
| @@ -39,10 +39,3 @@ class MobileScannerErrorDetails { | @@ -39,10 +39,3 @@ class MobileScannerErrorDetails { | ||
| 39 | /// The error message from the [PlatformException]. | 39 | /// The error message from the [PlatformException]. |
| 40 | final String? message; | 40 | final String? message; |
| 41 | } | 41 | } |
| 42 | - | ||
| 43 | -/// This class represents an exception that is thrown | ||
| 44 | -/// when the scanner was (re)started while a permission request was pending. | ||
| 45 | -/// | ||
| 46 | -/// This exception type is only used internally, | ||
| 47 | -/// and is not part of the public API. | ||
| 48 | -class PermissionRequestPendingException implements Exception {} |
| @@ -38,12 +38,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -38,12 +38,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 38 | /// The container div element for the camera view. | 38 | /// The container div element for the camera view. |
| 39 | late HTMLDivElement _divElement; | 39 | late HTMLDivElement _divElement; |
| 40 | 40 | ||
| 41 | - /// The flag that keeps track of whether a permission request is in progress. | ||
| 42 | - /// | ||
| 43 | - /// On the web, a permission request triggers a dialog, that in turn triggers a lifecycle change. | ||
| 44 | - /// While the permission request is in progress, any attempts at (re)starting the camera should be ignored. | ||
| 45 | - bool _permissionRequestInProgress = false; | ||
| 46 | - | ||
| 47 | /// The stream controller for the media track settings stream. | 41 | /// The stream controller for the media track settings stream. |
| 48 | /// | 42 | /// |
| 49 | /// Currently, only the facing mode setting can be supported, | 43 | /// Currently, only the facing mode setting can be supported, |
| @@ -187,14 +181,9 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -187,14 +181,9 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 187 | 181 | ||
| 188 | try { | 182 | try { |
| 189 | // Retrieving the media devices requests the camera permission. | 183 | // Retrieving the media devices requests the camera permission. |
| 190 | - _permissionRequestInProgress = true; | ||
| 191 | - | ||
| 192 | final MediaStream videoStream = | 184 | final MediaStream videoStream = |
| 193 | await window.navigator.mediaDevices.getUserMedia(constraints).toDart; | 185 | await window.navigator.mediaDevices.getUserMedia(constraints).toDart; |
| 194 | 186 | ||
| 195 | - // At this point the permission is granted. | ||
| 196 | - _permissionRequestInProgress = false; | ||
| 197 | - | ||
| 198 | return videoStream; | 187 | return videoStream; |
| 199 | } on DOMException catch (error, stackTrace) { | 188 | } on DOMException catch (error, stackTrace) { |
| 200 | final String errorMessage = error.toString(); | 189 | final String errorMessage = error.toString(); |
| @@ -209,10 +198,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -209,10 +198,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 209 | errorCode = MobileScannerErrorCode.permissionDenied; | 198 | errorCode = MobileScannerErrorCode.permissionDenied; |
| 210 | } | 199 | } |
| 211 | 200 | ||
| 212 | - // At this point the permission request completed, although with an error, | ||
| 213 | - // but the error is irrelevant. | ||
| 214 | - _permissionRequestInProgress = false; | ||
| 215 | - | ||
| 216 | throw MobileScannerException( | 201 | throw MobileScannerException( |
| 217 | errorCode: errorCode, | 202 | errorCode: errorCode, |
| 218 | errorDetails: MobileScannerErrorDetails( | 203 | errorDetails: MobileScannerErrorDetails( |
| @@ -268,13 +253,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | @@ -268,13 +253,6 @@ class MobileScannerWeb extends MobileScannerPlatform { | ||
| 268 | 253 | ||
| 269 | @override | 254 | @override |
| 270 | Future<MobileScannerViewAttributes> start(StartOptions startOptions) async { | 255 | Future<MobileScannerViewAttributes> start(StartOptions startOptions) async { |
| 271 | - // If the permission request has not yet completed, | ||
| 272 | - // the camera view is not ready yet. | ||
| 273 | - // Prevent the permission popup from triggering a restart of the scanner. | ||
| 274 | - if (_permissionRequestInProgress) { | ||
| 275 | - throw PermissionRequestPendingException(); | ||
| 276 | - } | ||
| 277 | - | ||
| 278 | _barcodeReader = ZXingBarcodeReader(); | 256 | _barcodeReader = ZXingBarcodeReader(); |
| 279 | 257 | ||
| 280 | await _barcodeReader?.maybeLoadLibrary( | 258 | await _barcodeReader?.maybeLoadLibrary( |
-
Please register or login to post a comment