imp: reinstated onStart but made it deprecated so it doesn't break immediately.
Showing
1 changed file
with
8 additions
and
1 deletions
| @@ -22,6 +22,10 @@ class MobileScanner extends StatefulWidget { | @@ -22,6 +22,10 @@ class MobileScanner extends StatefulWidget { | ||
| 22 | final void Function(BarcodeCapture barcodes) onDetect; | 22 | final void Function(BarcodeCapture barcodes) onDetect; |
| 23 | 23 | ||
| 24 | /// The function that signals when the barcode scanner is started. | 24 | /// The function that signals when the barcode scanner is started. |
| 25 | + @Deprecated('Use onScannerStarted() instead.') | ||
| 26 | + final void Function(MobileScannerArguments? arguments)? onStart; | ||
| 27 | + | ||
| 28 | + /// The function that signals when the barcode scanner is started. | ||
| 25 | final void Function(MobileScannerArguments? arguments)? onScannerStarted; | 29 | final void Function(MobileScannerArguments? arguments)? onScannerStarted; |
| 26 | 30 | ||
| 27 | /// The function that builds a placeholder widget when the scanner | 31 | /// The function that builds a placeholder widget when the scanner |
| @@ -36,6 +40,7 @@ class MobileScanner extends StatefulWidget { | @@ -36,6 +40,7 @@ class MobileScanner extends StatefulWidget { | ||
| 36 | this.controller, | 40 | this.controller, |
| 37 | this.fit = BoxFit.cover, | 41 | this.fit = BoxFit.cover, |
| 38 | required this.onDetect, | 42 | required this.onDetect, |
| 43 | + @Deprecated('Use onScannerStarted() instead.') this.onStart, | ||
| 39 | this.onScannerStarted, | 44 | this.onScannerStarted, |
| 40 | this.placeholderBuilder, | 45 | this.placeholderBuilder, |
| 41 | super.key, | 46 | super.key, |
| @@ -60,6 +65,8 @@ class _MobileScannerState extends State<MobileScanner> | @@ -60,6 +65,8 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 60 | /// Start the given [scanner]. | 65 | /// Start the given [scanner]. |
| 61 | void _startScanner(MobileScannerController scanner) { | 66 | void _startScanner(MobileScannerController scanner) { |
| 62 | scanner.start().then((arguments) { | 67 | scanner.start().then((arguments) { |
| 68 | + // ignore: deprecated_member_use_from_same_package | ||
| 69 | + widget.onStart?.call(arguments); | ||
| 63 | widget.onScannerStarted?.call(arguments); | 70 | widget.onScannerStarted?.call(arguments); |
| 64 | }); | 71 | }); |
| 65 | } | 72 | } |
| @@ -69,7 +76,7 @@ class _MobileScannerState extends State<MobileScanner> | @@ -69,7 +76,7 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 69 | super.initState(); | 76 | super.initState(); |
| 70 | WidgetsBinding.instance.addObserver(this); | 77 | WidgetsBinding.instance.addObserver(this); |
| 71 | _controller = widget.controller ?? MobileScannerController(); | 78 | _controller = widget.controller ?? MobileScannerController(); |
| 72 | - | 79 | + |
| 73 | _barcodesSubscription = _controller.barcodes.listen( | 80 | _barcodesSubscription = _controller.barcodes.listen( |
| 74 | widget.onDetect, | 81 | widget.onDetect, |
| 75 | ); | 82 | ); |
-
Please register or login to post a comment