Committed by
GitHub
Merge pull request #1400 from juliansteenbakker/hotfix/on-detect
fix: fix on detect not working when controller is provided
Showing
1 changed file
with
4 additions
and
0 deletions
| @@ -278,12 +278,16 @@ class _MobileScannerState extends State<MobileScanner> | @@ -278,12 +278,16 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 278 | 278 | ||
| 279 | if (widget.controller == null) { | 279 | if (widget.controller == null) { |
| 280 | WidgetsBinding.instance.addObserver(this); | 280 | WidgetsBinding.instance.addObserver(this); |
| 281 | + } | ||
| 282 | + | ||
| 283 | + if (widget.onDetect != null) { | ||
| 281 | _subscription = controller.barcodes.listen( | 284 | _subscription = controller.barcodes.listen( |
| 282 | widget.onDetect, | 285 | widget.onDetect, |
| 283 | onError: widget.onDetectError, | 286 | onError: widget.onDetectError, |
| 284 | cancelOnError: false, | 287 | cancelOnError: false, |
| 285 | ); | 288 | ); |
| 286 | } | 289 | } |
| 290 | + | ||
| 287 | if (controller.autoStart) { | 291 | if (controller.autoStart) { |
| 288 | await controller.start(); | 292 | await controller.start(); |
| 289 | } | 293 | } |
-
Please register or login to post a comment