Showing
1 changed file
with
9 additions
and
1 deletions
| @@ -119,18 +119,26 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | @@ -119,18 +119,26 @@ class MobileScannerController extends ValueNotifier<MobileScannerState> { | ||
| 119 | void _setupListeners() { | 119 | void _setupListeners() { |
| 120 | _barcodesSubscription = MobileScannerPlatform.instance.barcodesStream | 120 | _barcodesSubscription = MobileScannerPlatform.instance.barcodesStream |
| 121 | .listen((BarcodeCapture? barcode) { | 121 | .listen((BarcodeCapture? barcode) { |
| 122 | - if (barcode != null) { | 122 | + if (!_barcodesController.isClosed && barcode != null) { |
| 123 | _barcodesController.add(barcode); | 123 | _barcodesController.add(barcode); |
| 124 | } | 124 | } |
| 125 | }); | 125 | }); |
| 126 | 126 | ||
| 127 | _torchStateSubscription = MobileScannerPlatform.instance.torchStateStream | 127 | _torchStateSubscription = MobileScannerPlatform.instance.torchStateStream |
| 128 | .listen((TorchState torchState) { | 128 | .listen((TorchState torchState) { |
| 129 | + if (_isDisposed) { | ||
| 130 | + return; | ||
| 131 | + } | ||
| 132 | + | ||
| 129 | value = value.copyWith(torchState: torchState); | 133 | value = value.copyWith(torchState: torchState); |
| 130 | }); | 134 | }); |
| 131 | 135 | ||
| 132 | _zoomScaleSubscription = MobileScannerPlatform.instance.zoomScaleStateStream | 136 | _zoomScaleSubscription = MobileScannerPlatform.instance.zoomScaleStateStream |
| 133 | .listen((double zoomScale) { | 137 | .listen((double zoomScale) { |
| 138 | + if (_isDisposed) { | ||
| 139 | + return; | ||
| 140 | + } | ||
| 141 | + | ||
| 134 | value = value.copyWith(zoomScale: zoomScale); | 142 | value = value.copyWith(zoomScale: zoomScale); |
| 135 | }); | 143 | }); |
| 136 | } | 144 | } |
-
Please register or login to post a comment