Skip to content

Commit 58f2df7

Browse files
Merge pull request juliansteenbakker#1400 from juliansteenbakker/hotfix/on-detect
fix: fix on detect not working when controller is provided
2 parents 229d9ad + c0207b2 commit 58f2df7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/src/mobile_scanner.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,16 @@ class _MobileScannerState extends State<MobileScanner>
278278

279279
if (widget.controller == null) {
280280
WidgetsBinding.instance.addObserver(this);
281+
}
282+
283+
if (widget.onDetect != null) {
281284
_subscription = controller.barcodes.listen(
282285
widget.onDetect,
283286
onError: widget.onDetectError,
284287
cancelOnError: false,
285288
);
286289
}
290+
287291
if (controller.autoStart) {
288292
await controller.start();
289293
}

0 commit comments

Comments
 (0)