report unavailable instead of off when stopping the camera if there was no torch
Showing
1 changed file
with
6 additions
and
1 deletions
| @@ -313,11 +313,16 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | @@ -313,11 +313,16 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | ||
| 313 | 313 | ||
| 314 | _disposeListeners(); | 314 | _disposeListeners(); |
| 315 | 315 | ||
| 316 | + final TorchState oldTorchState = value.torchState; | ||
| 317 | + | ||
| 316 | // After the camera stopped, set the torch state to off, | 318 | // After the camera stopped, set the torch state to off, |
| 317 | // as the torch state callback is never called when the camera is stopped. | 319 | // as the torch state callback is never called when the camera is stopped. |
| 320 | + // If the device does not have a torch, do not report "off". | ||
| 318 | value = value.copyWith( | 321 | value = value.copyWith( |
| 319 | isRunning: false, | 322 | isRunning: false, |
| 320 | - torchState: TorchState.off, | 323 | + torchState: oldTorchState == TorchState.unavailable |
| 324 | + ? TorchState.unavailable | ||
| 325 | + : TorchState.off, | ||
| 321 | ); | 326 | ); |
| 322 | 327 | ||
| 323 | await MobileScannerPlatform.instance.stop(); | 328 | await MobileScannerPlatform.instance.stop(); |
-
Please register or login to post a comment