Julian Steenbakker

hotfix: fix on detect not working when controller is provided

@@ -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 }